Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Chart and Colors
kosta
<p>Hello BIRT community,</p><p> </p><p>is it possible to colors from the rows data. (BIRT 2.6.2)</p><p> </p><p>I have a row as a java object. The object has getters for the R;G;B colors.</p><p>I am trying to read the data from objects and use it in the chart.</p><pre class="_prettyXprint _linenums:1">importPackage( Packages.org.eclipse.birt.chart.model.data );importPackage( Packages.org.eclipse.birt.chart.model.data.impl );importPackage( Packages.org.eclipse.birt.chart.model.impl );importPackage( Packages.org.eclipse.birt.chart.model.type.impl );importPackage( Packages.org.eclipse.birt.chart.model.attribute );importPackage( Packages.org.eclipse.birt.chart.model.attribute.impl );importPackage( Packages.com.somepackage );function beforeGeneration( chart, icsc ) { sd = chart.getAxes().get(0).getAssociatedAxes().get(0).getSeriesDefinitions().get(0); sd.getSeriesPalette().getEntries().clear(); red = new Number(row["Object"].getColor().getR()); green = new Number(row["Object"].getColor()getG()); blue = new Number(row["Object"].getColor().getB()); sd.getSeriesPalette().getEntries().add(GradientImpl.create( ColorDefinitionImpl.create(red, green, blue), ColorDefinitionImpl.create(red, green, blue), -35, false ));}</pre><p>Is this kind of approach possible?</p><p> </p><p>For any sugesstions and hints thanks in advance,</p>
Find more posts tagged with
Comments
kclark
<p>You could set the values in the row's your pulling from to a PGV then do something like this</p><pre class="_prettyXprint">function beforeDrawDataPoint( dph, fill, icsc ){ var r = parseInt(icsc.getExternalContext().getScriptable().getPersistentGlobalVariable("r")); var g = parseInt(icsc.getExternalContext().getScriptable().getPersistentGlobalVariable("g")); var b = parseInt(icsc.getExternalContext().getScriptable().getPersistentGlobalVariable("b")); fill.set(r,g,b);}</pre>
kosta
<p>Thanks for the fast reply Kris,</p><p> </p><p>the PGV (<span>PersistentGlobalVariable</span>) solution is a nice hint, thank you.</p><p>At the beginning I had problems with that because I guess haven't import the package for the objects from which the RGB data is readed from.</p><p> </p><p>I am using the same code from above in the beforeGenertaion-method.</p><p> </p><p>Also this link helped me to understand better the PersistentGlobalVariable:</p><p><a data-ipb='nomediaparse' href='
http://stackoverflow.com/questions/1227947/birt-adding-total-from-multiple-dataset'>http://stackoverflow.com/questions/1227947/birt-adding-total-from-multiple-dataset</a></p><p> </p><p>Cheers.</p>
;
kclark
<p>No problem, glad it helped!
</p>