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

Message ListMessage List     Post MessagePost Message

  Set Maximum of Y-axis to 100 Percent using autoscale....
Posted by Divya on Dec-23-2013 13:39
Hello,

Here is am facing a problem of setting the Maximum of auto scale to 100 % on a
percentage chart.

I am wroking on two kinds of charts Barks with Marks and trend line charts.So both have
a goal /Target line which some times would be 100 % .So when i set the Linear scale like
:

c1.yAxis().setLinearScale(0, 120, 20);

Its not setting maximum 120 but making the highest as 120 which i don't want.I want to
set the autoscale according to the obtained data which is not possible in the above
case, if i make the 120 to 100 The plotarea border and the Taget line are overlapping and
its looking odd.Taking your  one of the suggestion on the other question I have applied
the following code:

c1.yAxis().setLinearScale(Chart.NoValue, 120);
c1.yAxis().setAutoScale(0, 0, 0.1);
c1.addText(25, 10, "     ").setBackground(0xdee7ff);

The addtext part is hidding the top most label of yaxis But now my chart has got two
points after 100 i.e 110% and 120% so its just hiding 120% but 110% is still visible.

But i don't want labels above 100% it should be max of 100% with a little space left after
the last label so that the target line is clearly visible.

Please help me in achieving this.This is on a high priority one for me as of now.

Thanks In Advance.

  Re: Set Maximum of Y-axis to 100 Percent using autoscale....
Posted by Peter Kwan on Dec-23-2013 16:08
Hi Divya,

You can use Axis.setMargin to add a margin on the top with no scale. An example is at:

http://www.advsofteng.com/doc/cdnet.htm#multibar.htm

For your case, you may use:

c1.yAxis().setMargin(10);

Hope this can help.

Regards
Peter Kwan

  Re: Set Maximum of Y-axis to 100 Percent using autoscale....
Posted by Divya on Dec-25-2013 00:26
Attachments:
Hello Peter,

Thanks for the help it worked fine.

But my concern here is that chartdiector is taking different Scaling ranges for different
different charts for same type of data.

Suppose if data is 20% for two charts One of those Yaxis is starting from 0.0% and other
chart it is starting from 20.0% thou the settings are same for both.Can you let me know
why this is happening?

The two charts are as below:
Autoscale1.PNG
AutoScale2.PNG

  Re: Set Maximum of Y-axis to 100 Percent using autoscale....
Posted by Peter Kwan on Dec-25-2013 01:56
Hi Divya,

In your first chart, the two data values are 20.5 and 20.6 (the values are displayed on the chart as data labels). So the chart scale is 20 to 100.

In your first chart, the two data values are 18.9 and 18.9. So the chart scale is 0 to 100.

Because the two charts are using completely different data, so it is normal the scale is different.

Would you mind to clarify what scale do you expect in these two charts? If you want the scale to be 0 to 100 regardless of the actual data, you can always use setLinearScale to set it to 0 to 100.

Regards
Peter Kwan

  Re: Set Maximum of Y-axis to 100 Percent using autoscale....
Posted by Divya on Dec-30-2013 15:39
Hi peter ,

The issue here is in the chart 18.6 data is shown clearly but when it comes to 20.6 though
it is larger than 18.6 its is showing a very minute line which can mislead the user when they
look at it..

Can i do something to set the starting x-label to 0 even when the value is 20.6? Or when it
is < 30?

Thanks
Divya

  Re: Set Maximum of Y-axis to 100 Percent using autoscale....
Posted by Peter Kwan on Dec-31-2013 03:15
Hi Divya,

By default, if the lower y-axis limit is automatically determined by ChartDirector, ChartDirector will ensure there is at least a 5% margin. In your case, there is almost no margin at all. I look at your previous code, and find that you have disabled the margin by using setAutoScale:

c1.yAxis().setAutoScale(0, 0, 0.1);

If you do not want to disable the margin, please do not use 0 as the margin. You may use 0.05 instead.

c1.yAxis().setAutoScale(0.05, 0.05, 0.1);

Hope this can help.

Regards
Peter Kwan