|
Re: Bar Chart vertical axis scaling question [message #656229 is a reply to message #656047] |
Thu, 24 February 2011 16:01 |
|
You can manually scale a chart using a beforeGeneration script like:
function beforeGeneration(chart, icsc)
{
importPackage( Packages.org.eclipse.birt.chart.model.data.impl );
xAxis = chart.getBaseAxes()[0];
scale = xAxis.getScale();
scale.setStep (35);
xAxis.setScale(scale);
yAxis = chart.getOrthogonalAxes( xAxis, true)[0]
yscale = yAxis.getScale();
yscale.setStep (10);
yscale.setMin( NumberDataElementImpl.create(0) )
yscale.setMax( NumberDataElementImpl.create(25) )
yAxis.setScale(yscale);
}
If you want the min and max values to be based on the data your best bet
is to add two computed columns to your dataset, one that aggregates with
a min function and one with a max function. Then in the oncreate for
the header row of the list save the value like:
var max = this.getRowData().getColumnValue("maxcolumnname");
var min = this.getRowData().getColumnValue("mincolumnname");
reportContext.setPersistentGlobalVariable("chartmin", min);
reportContext.setPersistentGlobalVariable("chartmax", max);
Finally alter the beforeGeneration script above to get these values in
place of the hard coded 0 and 25.
var cmin =
icsc.getExternalContext().getScriptable().getPersistentGloba lVariable( "chartmin")
var cmax =
icsc.getExternalContext().getScriptable().getPersistentGloba lVariable( "chartmax")
yscale.setMin( NumberDataElementImpl.create(cmin) )
yscale.setMax( NumberDataElementImpl.create(cmax) )
Jason
On 2/23/2011 4:38 PM, Jim Garrison wrote:
> I have a report with the following structure
>
>
> LIST
> GROUP
> HEADER
> DETAIL (empty)
> FOOTER
> CHART
>
>
> This produces one chart image per grouping key value, which is what I
> want. However, the vertical scale on each chart is dependent only on the
> data in that chart. I want to scale all the charts produced with the
> same minimum (always zero) and maximum values, using the largest maximum
> for any of the charts.
>
> A concrete example:
>
> The data set contains three distinct values for the grouping key, so
> there are three output charts. The first chart has a vertical range of
> 0-10, the second a range of 0-25 and the third a range of 0-8.
> Presently, each chart scales independently so the bar heights on the
> three different charts are not visually comparable. I want all three
> charts to use the scale 0-25 so the bar heights represent the same
> values from chart to chart.
>
> Can this be accomplished from the Eclipse designer, or by editing the
> XML? I looked at the XML and find that the scale values seem to be
> constants only and do not allow expressions.
|
|
|
|
Re: Bar Chart vertical axis scaling question [message #656272 is a reply to message #656261] |
Thu, 24 February 2011 20:09 |
|
Jim,
This post may help you:
http://birtworld.blogspot.com/2010/08/birt-charting-scriptin g-overview.html
Jason
On 2/24/2011 2:13 PM, Jim Garrison wrote:
> Thanks very much for the help. I'll try this approach (and learn
> something about scripting BIRT in the bargain :)
|
|
|
Powered by
FUDForum. Page generated in 0.03277 seconds