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)
How do you access a dataset from chart
newbie321
<p style="font-size:15px;font-family:'Helvetica Neue', Helvetica, Arial, sans-serif;">Hello, </p>
<p style="font-size:15px;font-family:'Helvetica Neue', Helvetica, Arial, sans-serif;">I have a chart element in .rptdesign file. it uses the dataset that has two columns (<strong>x</strong>,<strong>y</strong>) and are used to make the plot. </p>
<p style="font-size:15px;font-family:'Helvetica Neue', Helvetica, Arial, sans-serif;">Now depending on how many points are the dataset, I would need to <strong>dynamically</strong> adjust the properties of the chart, through the beforeGeneration() event handler or any other applicable event handler.</p>
<p style="font-size:15px;font-family:'Helvetica Neue', Helvetica, Arial, sans-serif;">Question: how do I access dataset list values from within the beforeGeneration() event handler as shown below:</p>
<p>function beforeGeneration( chart, icsc )<br>
{<br>
importPackage( Packages.org.eclipse.birt.chart.model.data.impl );<br>
totalPoints = ????? <br>
}</p>
<p> </p>
<p style="font-size:15px;font-family:'Helvetica Neue', Helvetica, Arial, sans-serif;">Thanks!!</p>
Find more posts tagged with
Comments
newbie321
<p>I actually found a solution which I present below for the benefit of the community:</p>
<p> </p>
<p style="color:rgb(40,40,40);font-family:'Source Sans Pro', sans-serif;">In the </p>
<pre class="_prettyXprint">
.beforeGeneration()</pre>
<p style="color:rgb(40,40,40);font-family:'Source Sans Pro', sans-serif;">do the following:</p>
<div style="margin:0px;color:rgb(40,40,40);font-family:'Source Sans Pro', sans-serif;">
<pre class="_prettyXprint">
data = chart.getAxes().get(0).getAssociatedAxes().get(0).getRuntimeSeries()[0].getDataSet().getValues();</pre>
<p>The <strong>data</strong> will be of an <strong>Array </strong>type. So all you have to do is to cycle through the an array using the classic approach:</p>
<pre class="_prettyXprint">
for (i=0; i<data.length;i++){
System.out.println(data[i]);
}</pre>
<p>At this point of time the data corresponding to y-axis is exposed. </p>
</div>
JFreeman
<p>Sorry I was not able to get to this sooner.</p>
<p>
Thank you for providing the solution you have found for the issue.<br>
I am glad to hear you got it working.</p>
<p>
Let us know if you have additional questions.</p>