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)
Change chart series color based on third value
boris256
I have a line chart with Y series grouping. I want to dynamically set the color for each series based not on the X value or the Y value, but another value (that exists for each record in the data set).
In other words, can I look up, for each series, all of its associated data, and not just the X and Y data points? I would guess this should be executed in function beforeDrawSeries.
Find more posts tagged with
Comments
kclark
You can use series.getDataSet().getValues() in the beforeDrawSeries()<br />
<br />
If you use this<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>function beforeDrawSeries( series, isr, icsc )
{
values = series.getDataSet().getValues();
icsc.getExternalContext().getScriptable().setPersistentGlobalVariable("values",test);
}</pre>
<br />
That will store the it in the PGV values. You said you need all of the associated data. What value are you looking for that will change the color?<br />
<br />
You can see the output of the PGV if you add a dynamic text object to your report and use this<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>reportContext.getPersistentGlobalVariable("test").join(", ");</pre>
boris256
Thanks! <br />
<br />
How do I look inside the values object? Each of my series should have either 2 or 3 data points, with five fields for each data point (two of which are used as the X and Y coordinates). How would I look up a particular field? Can I iterate through the data points? I don't need to store the data in the PGV; I'd rather add logic directly within beforeDrawSeries to assign color to each series as it's processed.<br />
<br />
<br />
<br />
<blockquote class='ipsBlockquote' data-author="'kclark'" data-cid="113530" data-time="1358973817" data-date="23 January 2013 - 01:43 PM"><p>
You can use series.getDataSet().getValues() in the beforeDrawSeries()<br />
<br />
If you use this<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>function beforeDrawSeries( series, isr, icsc )
{
values = series.getDataSet().getValues();
icsc.getExternalContext().getScriptable().setPersistentGlobalVariable("values",test);
}</pre>
<br />
That will store the it in the PGV values. You said you need all of the associated data. What value are you looking for that will change the color?<br />
<br />
You can see the output of the PGV if you add a dynamic text object to your report and use this<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>reportContext.getPersistentGlobalVariable("test").join(", ");</pre></p></blockquote>