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)
How to access data set from chart
pau
Hello,
I would like to know how can I access dataset from script events for chart.
What I am trying to achieve here is:
1. I have a dataset that has three columns, suppose columnA, columnB, and columnC.
2. In a Bar chart, columnA and columnB are plotted on X-Axis and Y-axis respectively.
3. Bars are colored based on the values in ColumnC.
Please note that the size of the dataset is variable.
I have noticed in a different thread where three bars were colored based on 3 highest credit limits. In that case, global variable was used to accomplish the task. Since in this case the number is not limited to 3, and more importantly - very unpredictable,
I am fairly new to this technology (less than a week). Any help is very much appreciated.
Regards
Find more posts tagged with
Comments
mwilliams
Hi pau,
Can you post some sample data? What version of BIRT are you using?
pau
<blockquote class='ipsBlockquote' data-author="mwilliams"><p>Can you post some sample data?</p></blockquote>
<br />
Name Account Balance Account Status<br />
A -10 Poor<br />
B 100 Good<br />
C 1000000 Excellent <br />
D 5000 Good<br />
E -5 Poor<br />
<br />
Now I would be plotting Customer name as category and Account balance as value. Also, I would be using Math.abs() function on value. And I would color bars based on the account status.<br />
<br />
<br />
<blockquote class='ipsBlockquote' data-author="mwilliams"><p>What version of BIRT are you using?</p></blockquote>
<br />
Birt 2.3.1<br />
<br />
Thanks for your reply
mwilliams
pau,
Are poor, good, and excellent based entirely off of account balance or something else?
pau
<blockquote class='ipsBlockquote' data-author="mwilliams"><p>pau,<br />
<br />
Are poor, good, and excellent based entirely off of account balance or something else?</p></blockquote>
<br />
<br />
Lets assume that it is based on account balance. I have a range to define the status. Any negative value would be poor, 0 - 20,000 is good, and above 20,000 is excellent. This validation is not part of the report. Another script does the validation to determine the status and writes the status along with name and account balance into the table. The report has to read the table and render graph.
mwilliams
pau,
If it's not based solely on balance, then my suggestion of using marker lines to determine the color change, would not work. I have an idea of something that will work. I'll post an example when I come up with something.
mwilliams
pau,
One thing you can definitely do is to create persistentGlobalVariables with the name of the x-axis value and make the color the value of the pGV. Then in the chart you can call those global variables by using the chart's x-axis value and set the color accordingly. I believe there is also a way to pass dataSet data that's not used in the chart through interactivity on the chart as well. I'll let you know if I find info on that.
mwilliams
pau,
Ok, if you go to your chart editor, go to the format chart tab, go to value series, click on the interactivity button....choose Key Up or any event, choose show tooltip for the action, click on the expression builder button and choose the account status field. This will give you access to use this value in your chart script.
In the script, you can access that value by using the following:
dph.getUserValue("row["AccountStatus"]")
inside the beforeDrawDataPoint function, compare it to your 3 possible values in an if/else statement and use 'fill.set(R,G,B)' to change the color accordingly.
Hope this helps.