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)
Same scale with two charts
xpaterna
Hi,
I've a stupid problem. I have two charts in a report, and I want to show both with the same scale.
The problem is that I don't know what's the perfect maximum value for the chart, so the automatic scale is perfect of birt is perfect for me.
So is there any option to pre-calculate the maximum number of the two charts before the generation of both?
Thank you very much!
Find more posts tagged with
Comments
kclark
If you have grouping or aggregated data in the charts then you would need to make a copy of the second chart, make it hidden, and place it before the first chart. Then you can check the values of the duplicate chart with some scripting. Then you could compare the values to that of chart #1 and apply the min and max values to chart 1 and 2.
xpaterna
<blockquote class='ipsBlockquote' data-author="'kclark'" data-cid="112222" data-time="1354920424" data-date="07 December 2012 - 03:47 PM"><p>
If you have grouping or aggregated data in the charts then you would need to make a copy of the second chart, make it hidden, and place it before the first chart. Then you can check the values of the duplicate chart with some scripting. Then you could compare the values to that of chart #1 and apply the min and max values to chart 1 and 2.<br /></p></blockquote>
<br />
Hi kclark!<br />
<br />
Thanks for replying again. I've tried your solution, the problem is that when I try to get the max value, it always returns null. I've read that max value is available after the event "aftercomputations", but I can't get another thing that null...<br />
<br />
Did you tried this? What can I do? I think in some moment the max value must be setted, but in what event?<br />
<br />
Thanks again for your time.<br />
<br />
EDIT 12/10/2012:<br />
<br />
I've found the solution, it's not trivial!<br />
In the beforeGeneration script, you haven't yet the Max value of the chart, so you can retrive the Max value in the afterComputations script.<br />
<br />
This is an example to get the Max value and store it into a global variable:<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
function afterComputations( chart, plotComputation )
{
var max = plotComputation.getAxes().getPrimaryOrthogonal().getScale(). getMaximum();
plotComputation.getRunTimeContext().getScriptContext().getExternalContext().getScriptable().setPersistentGlobalVariable("MaxChart",max.toString());
}
</pre>