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

Message ListMessage List     Post MessagePost Message

  yAxis
Posted by Helmut on Jan-03-2018 02:21
Attachments:
Hi Peter,

with, the highest tolerance 2.30 is not displayed everywhere.
I used the standard.

minValue = 2.2
maxValue = 2.3
Call c.yAxis (). SetLinearScale (minValue, maxValue, 0.01)
Call c.layout
minValue = c.yAxis (). getMinValue ()
maxValue = c.yAxis (). getMaxValue ()

Is there a trick?

Regards Helmut
Trendline.jpg

  Re: yAxis
Posted by Peter Kwan on Jan-03-2018 17:09
Hi Helmut,

The reason is because the maxValue in your code is not 2.3. It is an impossible value.

Many fractional values cannot be represented exactly. For example, 1/3 cannot be represented exactly in decimal. You can use 0.333333, but it is not exactly equal to 1/3.

The value 2.3 can be represented exactly in decimal, but not in VB6. VB6 does not decimal, but use "Single" or "Double", which are floating point numbers in binary. In floating point format, 2.3 cannot be represented exactly, just like 1/3 cannot be represented exactly in decimal format. (VB6 will compile the code into binary before running the code, so ChartDirector cannot see your source code. It only sees the binary value which is not exactly equal to 2.3.)

To check if maxValue is 2.3 or not, you can try:

Debug.Print (23 - maxValue * 10)

If maxValue is 2.3, the above should be 0. If it is not 0, the maxValue is not equal to 2.3. In my test, the maxValue is slightly smaller than 2.3.

To solve the problem for your case, there are several methods:

(a) If you are using Single precision numbers, please use Double precision numbers. (Use Dim maxValue As Double). The single precision number is very inaccurate. It only has 7 to 8 digits of accuracy. So even an integer like 1234567890 cannot be represented exactly. In my testing, if maxValue is double precision, it works.

(If the tolerance is small enough, ChartDirector will assume it to be due to floating point errors and adjust it to 2.3. But single precision error is too large.)

(b) Do not specify the tick increment, just use:

Call c.yAxis().setLinearScale(minValue, maxValue)

If you do not specify the tick increment, ChartDirector will automatically determine the tick increment. In the process, ChartDirector may adjust the minValue and maxValue to fit the tick increment, so as to make sure the axis end-points are at a tick position.

If you specify all minValue, maxValue and tick increment, ChartDirector will follow your setting exactly. since maxValue is less than 2.3, the top axis endpoint will not have the 2.3 tick.

(c) Try to add a small value to maxValue:

maxValue = maxValue + maxValue / 1000000

The maxValue / 1000000 should not be visible on the chart, but it ensures the maxValue to be bigger than the 2.3 value rather than smaller, so the tick will appear.

Regards
Peter Kwan

  Re: yAxis
Posted by Helmut on Jan-03-2018 17:33
Hi Peter,

Thanks for your help.
That will help me in the future.

Regards Helmut