Skip to main content



      Home
Home » Archived » BIRT » Change the maximum value for y axis(The maximum value of y axis is always one more then the maximum dataset value, this is problem for multiple y axes)
Change the maximum value for y axis [message #1383997] Tue, 27 May 2014 14:31 Go to next message
Eclipse UserFriend
Greetings,

I have tried it for some time now but I am stuck.

Problem description
The maximum value for the y-axis is one plus the maximum value of the data displayed. I need the maximum value for the y-axis to be equal to the maximum value of the data displayed.

Reason behind the problem
I need to display a graph showing a bar chart with testcase statuses and display a line chart showing the expected progress to the same graph.
I have solved this by using second y-axis, but since the maximum values for those two charts are different, the place they occupy on the graph is different as well and they are on a different scale to each other. See the enclosed picture, I need the bars to end in the same height as the line chart.
Re: Change the maximum value for y axis [message #1384007 is a reply to message #1383997] Tue, 27 May 2014 15:51 Go to previous messageGo to next message
Eclipse UserFriend
There is no picture attached, but I think I get what you're saying. This can be fixed with script. You can grab the max value of your different series in the afterDataSetFilled function and then set the max values of the axes in, I believe, the beforeGeneration. This devShare post should show how to set the chart axis max. I know you don't want to do exactly what is in the post, but it should show you how to get you down the right path. Let me know if you need more help.
Re: Change the maximum value for y axis [message #1384212 is a reply to message #1383997] Wed, 28 May 2014 08:17 Go to previous messageGo to next message
Eclipse UserFriend
Hi Michael,

thank you very much for your help, I have followed the direction you have provided and successfully solved the problem.

I have added those lines in my dataset scripts to store the max value

 reportContext.setPersistentGlobalVariable("MaxPrdct",prdct.toString());
 reportContext.setPersistentGlobalVariable("MaxBar",maxBar.toString());


and I have used the following code in the beforeGeneration part of the chart script

 importPackage(Packages.org.eclipse.birt.chart.model.data.impl);
 xAxis = chart.getBaseAxes()[0];

 yAxis = chart.getOrthogonalAxes( xAxis, true )[0];
 max = icsc.getExternalContext().getScriptable().getPersistentGlobalVariable("MaxBar");
 yAxis.getScale().setMax(NumberDataElementImpl.create(max))

 yAxis = chart.getOrthogonalAxes( xAxis, true )[1];
 max = icsc.getExternalContext().getScriptable().getPersistentGlobalVariable("MaxPrdct");
 yAxis.getScale().setMax(NumberDataElementImpl.create(max))
Re: Change the maximum value for y axis [message #1384657 is a reply to message #1384212] Fri, 30 May 2014 00:28 Go to previous message
Eclipse UserFriend
Great to hear! Sorry to see that I forgot to paste the URL of the example. Glad you were able to figure it out from my description above! Thanks for posting your code! Smile

If you ever had aggregated values in your chart, rather than the exact values from your dataSet, you could get the max values from the afterDataSetFilled in the chart.
Previous Topic:Dataset that this chart uses has been changed. This chart can no longer be rendered.
Next Topic:Report Params & XML Data Sources
Goto Forum:
  


Current Time: Sat Jul 12 02:14:51 EDT 2025

Powered by FUDForum. Page generated in 0.03998 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top