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

Message ListMessage List     Post MessagePost Message

  Question about Axis.setMinTickInc
Posted by Jason on Dec-11-2018 03:13

I'm using C++ ChartDir 4.1 (I realize this is an old release, but I'm using it for "historical" reasons...)

My chart is a FinanceChart containing an XYChart (for high/low/open/close data) and an XYChart (for volume data).  This question is about the Y axis labels for the first XYChart (containing the high/low/open/close data).

In some cases my input data contains points which can vary by 1/128 (0.0078125), for example:

   - 105.6796875
   - 105.6718750
   - 105.6640625
   - ...
   - 105.5312500

For this data, I'm calling:


However the chart's Y axis labels are not coming out as I expected, see attached image.

This method works correctly for more "regular" tick sizes like 0.01, 0.000001, and 0.0000005.  It's only not working correctly for this "irregular" tick size of 0.0078125.

Is there a way to get the Y axis labels to come out as I'd like?  For example, in the image attached, I'd like to see the Y axis labels as:

   - 105.6796875
   - 105.6718750
   - ...
   - 105.6093750



  Re: Question about Axis.setMinTickInc
Posted by Peter Kwan on Dec-12-2018 05:49
Hi Jason,

When the axis is auto-scaled, the axis range will include the data range, but the labels on the axis does not come from the data values. For example, in the "Simple Bar Chart" sample code included in ChartDirector, the data values are 85, 156, 179.5, 211, 123, while the axis labels are 0, 50, 100, 150, 200, 250.

The setMinTickInc sets the minimum increment between two labels for auto-scaled axis. The most common usage of this method is to ensure the labels are integers (the minimum increment is 1), because in many applications, non-integers labels are not reasonable. (Eg, the data value can be the number of people, which must be integers). With setMinTickInc, ChartDirector can use a larger increment, but not a smaller increment.

For auto-scaling, for numeric labels, ChartDirector will only choose "1, 2, 5" increment (that is, .... 0.1, 0.2, 0.5, 1, 2, 5, 10, 20, 50, ....). It will not choose 0.0078125. So if this is the minimum increment, ChartDirector likely will choose a larger increment.

For your case, one method is to set the axis scale yourself. If you know the increment, it should be easy to determine the axis scale, and you can use Axis.setLinearScale to set the scale.

HLOCchart->yAxis()->setLinearScale(lowerValue, upperValue, increment);

Peter Kwan