Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
THRUST SERVICES & TOOLS
CLOUD EDITIONS
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
[fixed] Bar Chart Access to Dataset Values
Glide
Hi guys,<br />
<br />
I have a simple dataset of this kind:<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
+
+
+
+
| Client | Fees | Channel |
+
+
+
+
| xxxxxx | 1000000 | 1 |
| xxxxxx | 2000 | 1 |
| dfhdhg | 2000000 | 2 |
| dfhdhg | 3005000 | 3 |
| ... | ... | ... |
+
+
+
+
</pre>
<br />
And a bar chart with one bar per client.<br />
Now I'd like to change the color of each bar depending on the <strong class='bbc'>Channel</strong>.<br />
I found threads talking about changing colors depending on the <strong class='bbc'>bar value</strong>.<br />
But here it's not about the bar value but an <strong class='bbc'>other field value</strong>.<br />
I tried accessing the value by customizing this callback in the chart:<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
function beforeDrawDataPoint(dph, fill, icsc)
{
index = dph.getIndex();
seriesArray = icsc.getChartInstance().getAxes().get(0).getAssociatedAxes().get(0).getRuntimeSeries();
values = seriesArray[0].getDataSet().getValues()[index];
if (values['Channel'] == 1) {
fill.set(255, 0, 0);
}
}
</pre>
<br />
I have no error but the colors are not here.<br />
What do you think ?<br />
<br />
I have done an example file but I'm not able to upload it for whatever reason (Error This upload failed)<br />
I've just been able to upload a PDF of the example.
Find more posts tagged with
Comments
pricher
Hi,
Chart scripting is available only in the onRender event; at that point you do not have direct access to the data set, hence to values from columns that are not included in the chart.
The trick will be for you to create an array of values for "channel" that you will store as a persistent global variable, making it available in the onRender event.
I have attached an example that works with Classic Models. The data set returns 3 columns: productline, qty, and channel. The values for channel are stored in an array in the onCreate event of the detail row of the hidden table. That array is also stored as a persistent global variable for use in the onRender event of the chart. In the script for the chart, I get the array and apply a red color if channel equals 1.
It's a simple example that requires the values in the array to be in the same order as the bar in the charts.
Hope this helps!
P.
Glide
Actually this helps a lot.<br />
That's working just fine.<br />
Thank you !<br />
<br />
<blockquote class='ipsBlockquote' data-author="'pricher'" data-cid="74385" data-time="1299524657" data-date="07 March 2011 - 12:04 PM"><p>
Hi,<br />
<br />
Chart scripting is available only in the onRender event; at that point you do not have direct access to the data set, hence to values from columns that are not included in the chart.<br />
<br />
The trick will be for you to create an array of values for "channel" that you will store as a persistent global variable, making it available in the onRender event.<br />
<br />
I have attached an example that works with Classic Models. The data set returns 3 columns: productline, qty, and channel. The values for channel are stored in an array in the onCreate event of the detail row of the hidden table. That array is also stored as a persistent global variable for use in the onRender event of the chart. In the script for the chart, I get the array and apply a red color if channel equals 1.<br />
<br />
It's a simple example that requires the values in the array to be in the same order as the bar in the charts. <br />
<br />
Hope this helps!<br />
<br />
P.<br /></p></blockquote>
aelmrabti
I need help for a similar problem<br />
<br />
how can i link or use the persistent global variable (deduced from the onRender function) in the expression builder (associated to Jacascript interactivity scripting ) <br />
<br />
Thanx<br />
<br />
<br />
<blockquote class='ipsBlockquote' data-author="'Glide'" data-cid="74430" data-time="1299582392" data-date="08 March 2011 - 04:06 AM"><p>
Actually this helps a lot.<br />
That's working just fine.<br />
Thank you !<br /></p></blockquote>