|
How to know the labels number displayed on the vertical axis |
Posted by moses on Jan-29-2024 22:10 |
|
I didn't set any scale or maxmin bound for the axis, how to know how many labels are displayed on the axis? |
Re: How to know the labels number displayed on the vertical axis |
Posted by Peter Kwan on Jan-30-2024 13:52 |
|
Hi Moses,
Unless you set the scale for the vertical axis, ChartDirector will automatically determine the axis scale and labels based on all the data on the chart. ChartDirector will assume all the data have been added to the chart when one of the following happens:
(a) Your code call BaseChart.makeChart to generate the chart image or assign the chart to a chart viewer for display,
(b) Your code call BaseChart.layout or BaseChart.layoutAxes.
Note that after doing (a) or (b), you can no longer add layers to the chart (as your code should have already added all the data to the chart), but you can still modify the axis labels, add text, change colors, etc.
To get the axis min/max values, the APIs are Axis.getMaxValue and Axis.getMinValue. To get the position of the "ticks" on the axis, the API is Axis.getTicks. To determine the labels on the ticks, you can use Axis.getLabel.
The following post contains an example that iterates the ticks and custom format the axis labels (it is in C#, but the syntax is almost the same for C++):
https://www.chartdir.com/forum/download_thread.php?bn=chartdir_support&pattern=getTicks&thread=1669883401#N1669916213
See also:
https://www.advsofteng.com/doc/cdcpp.htm#BaseChart.layoutAxes.htm
https://www.advsofteng.com/doc/cdcpp.htm#BaseChart.layout.htm
https://www.advsofteng.com/doc/cdcpp.htm#Axis.getMinValue.htm
https://www.advsofteng.com/doc/cdcpp.htm#Axis.getMaxValue.htm
https://www.advsofteng.com/doc/cdcpp.htm#Axis.getTicks.htm
https://www.advsofteng.com/doc/cdcpp.htm#Axis.getLabel.htm
Best Regards
Peter Kwan |
|