ASE Home Page Products Download Purchase Support About ASE
ChartDirector Support
Forum HomeForum Home   SearchSearch

Message ListMessage List     Post MessagePost Message

  yaxis set margin not working with some data sets.
Posted by Jaideep on Jul-18-2013 01:10
Attachments:
Hi,

We are trying to pad the y-axis on charts with margins using yaxis.setmargin(topMargin,bottomMargin). In most cases this works fine, but in some cases the rendered chart just ignores the values.

For example a chart where we set yaxis.setmargin(50,50) with y axis data array consisting of the following values -
11.7021276595745
11.6959064327485
11.6094584286804
11.3484087102178
11.2952968388589
11.2361098356139
10.8194532293204
10.4864864864865
10.3896103896104
10.3846153846154
10.3448275862069

the margins are not rendered at all. Please see the attached image.

Is there another way to get this done?
Please let us know.

thanks,
Jaideep.
chartMargin2.PNG

  Re: yaxis set margin not working with some data sets.
Posted by Peter Kwan on Jul-18-2013 02:04
Hi Jaideep,

The margins work normally in your attached chart. There is a part at the top of the y-axis, and a part at the bottom of the y-axis that does not have numbers, and they are the margins.

Are you expecting that the bars to be started from 0 (so there would be 50 pixels of margin below 0)? If this is the case, you may use Axis.setAutoScale to ask ChartDirector to auto-scale the axis so that it always start from 0.

c.yAxis().setAutoScale(0.05, 0.05, 1)

Hope this can help.

Regards
Peter Kwan

  Re: yaxis set margin not working with some data sets.
Posted by Jaideep on Jul-18-2013 02:34
Attachments:
Peter,
Thanks for the response.
Yeah the idea is for the bars to start at the same level as the first number does (with a margin at the bottom).
Using your suggestion (and setting zero affinity to 1) gives the desired margin at the bottom, but the y -axis values are different.
Please see attached.
chartMargin3.PNG

  Re: yaxis set margin not working with some data sets.
Posted by Peter Kwan on Jul-19-2013 02:39
Hi Jaideep,

In your first message, you mentioned "In most cases this works fine, but in some cases the rendered chart just ignores the values." I think that with your original code, it can only work the way you want if the y-axis contain 0. So all charts that you think works fine should have a y-axis that contains 0. The code I suggested is to ensure the y-axis always contain 0, so that the charts produced will be of the "work fine" type.

As the code forces the y-axis to contain 0, so the y-axis would not be the same as the "does not work fine" charts. The important thing is that the resulting chart is correct - that the top end of the bar correctly reflects the data value of the bar.

If you prefer the y-axis to not starting from 0, but just want to cover the bottom part of the bars, you may consider to just add an empty text box (using BaseChart.addText) to the bottom of the plot area. You may use Box.setSize to set the size and Box.setBackground to set it as the same color as the plot area background.

Hope this can help.

Regards
Peter Kwan