|
ration in dual Y axis line chart |
Posted by Stephen on Jan-07-2011 11:29 |
|
Hi Peter,
Please see attached jpg file.
This chart is comparing 2 performance, one in actual amount and one in return % starting from index 1.
these 2 lines should start from the same spot, how can I do that?
I mean the blue line should start from the same spot at 1 on the left Y axis.
Obviously the right yaxis ratio must be adjusted.
what is the easy way to do that?
appreciated
regards
Stephen
|
Re: ration in dual Y axis line chart |
Posted by Peter Kwan on Jan-08-2011 02:19 |
|
Hi Stephen,
There are many methods to make the two lines start at the same point. You may shift the axis scale, or expand or compress the axis scale. An example is:
//set the scale of the right y-axis as a ratio to the left y-axis to make sure
//the myBlueData line and the myBlackData line starts at the same point
c.syncYAxis(myBlueData(0) / myBlackData(0));
//The following is optional - it sets independent axis labels (as opposed to synchronized labels)
c.yAxis().setRounding(false, false);
//The right y-axis is now not auto-scaled, but is constrained by the left y-axis scale. We
//want the left y-axis to be auto-scaled in a way that considers both myBlueData and myBlackData
ArrayMath a1 = new ArrayMath(myBlackData);
ArrayMath a2 = new ArrayMath(myBlueData);
c.yAxis().setLinearScale(Math.min(a1.min(), a2.min()), Math.max(a1.max(), a2.max()));
Hope this can help.
Regards
Peter Kwan |
|