|
Big numbers cause incorrect Y-axis labels |
Posted by Serge on Jun-29-2012 01:14 |
|
Hi,
To reproduce the problem, let's modify the 'simplebar.php' sample as follows.
change this line
$data = array(85, 156, 179.5, 211, 123);
to this one
$data = array(66695337642, 66698624000, 66694612650, 66692024320, 66689830229);
Let's also increase the left margin of the plot area.
$c->setPlotArea(80, 20, 150, 200);
The Y-axis labels are showing date/time !? (see chart1.png)
If I lower the first data point, e.g.
$data = array(16695337642, 66698624000, 66694612650, 66692024320, 66689830229);
the chart becomes correct (see chart2.png)
This appear to be a bug because the sample didn't request a date/time scale on the Y axis. (There is no call to setDateScale method)
How can I avoid this problem?
Calling setAutoScale method doesn't seem to help. Same with SetLinearScale3 - the labels remain date/time.
Serge
|
Re: Big numbers cause incorrect Y-axis labels |
Posted by Peter Kwan on Jun-29-2012 02:49 |
|
Hi Serge,
In PHP, there is no such thing as date/time. (In other programming languages, such as Java and .NET, there are data types like java.util.Date and System.DateTime for date/time.) So in PHP, we need to use numbers to represent date/time. The numbers represent the number of seconds elapsed since Jan 1, 0001 00:00:00.
This means given a number, it is now impossible to know if it is really a number, or a date/time, as date/time must also be represented as numbers in PHP. In ChartDirector, if you do not explicit specify the axis type, ChartDirector will try to "guess" if the numbers are really numbers or are date/time. If all the numbers are within the range 56770934400 to 69393715200 (which are from the year 1800 to 2200 in date/time), ChartDirector will assume the numbers are date/time and will use date/time formatting. If the numbers are really numbers, you would need to use Axis.setLinearScale3 to tell ChartDirector to use numeric scale instead of date/time scale.
$c->yAxis->setLinearScale3();
(For your data, if you do not tell me, I would have guessed they are date/time too. It is because from my experience all normally used date/time values are in this range, while it is uncommon for the data values to all fall in this range.)
Hope this can help.
Regards
Peter Kwan |
Re: Big numbers cause incorrect Y-axis labels |
Posted by Serge on Jun-29-2012 03:54 |
|
Hi Peter,
Thanks for the prompt reply.
I have used PHP for demonstration purposes only. My code is in C++ but it experiences the same error.
Perhaps I was not clear enough but I mentioned in my original post that your suggestion does not solve this problem, i.e.
$c->yAxis->setLinearScale3();
still produces an incorrect chart (see chart3.png)
|
Re: Big numbers cause incorrect Y-axis labels |
Posted by Peter Kwan on Jun-29-2012 22:24 |
|
Hi Serge,
Sorry. The correct code should be:
$c->yAxis->setLinearScale3("{value}");
The above applies to both PHP and C++.
Hope this can help.
Regards
Peter Kwan |
|