|
Get autoscale axis marker string |
Posted by David Littau on Aug-17-2011 03:23 |
|
Is there a way to get the string values used by chardirector when it graphs using autoscaling? I would like to change them.
I know I could just set the scale manually, and then replace the markings, but if there's an easier way I would prefer to use it.
thanks,
David |
Re: Get autoscale axis marker string |
Posted by Peter Kwan on Aug-17-2011 21:06 |
|
Hi David,
Yes. The code is like:
.... create chart as usual .....
//auto-scale axis
c.layout();
//get the label position
double[] ticks = c.yAxis().getTicks();
for (int i = 0; i < ticks.Length; ++i) {
string axisLabel = c.yAxis().getLabel(ticks[i]);
.... modify the label based on the position ticks[i] or the original axisLabel ....
c.yAxis().addLabel(ticks[i], modifiedLabel);
}
Hope this can help.
Regards
Peter Kwan |
Re: Get autoscale axis marker string |
Posted by David Littau on Aug-18-2011 05:37 |
|
This definitely solved my problem. The only thing I would add is that one needs to check the result of getLabel() to see if the return string is null. For some reason I got more ticks defined than had labels assigned to them.
thanks,
David |
Re: Get autoscale axis marker string |
Posted by David Littau on Aug-18-2011 05:44 |
|
Note that my null problem could be due to my setting the axis manually. I am not using autoscaling, but I still needed a way to replace the labels, and this worked. |
Re: Get autoscale axis marker string |
Posted by Peter Kwan on Aug-18-2011 22:35 |
|
Hi David,
If you are setting the axis manually, you can set the labels directly. For example, you may use Axis.setLinearScale2 to simultaneously define the axis scale and the labels and the minor tick position. (For the minor tick position, use "-" as the label. ChartDirector will treat any label that starts with a "-" to mean a minor tick.)
Hope this can help.
Regards
Peter Kwan |
|