|
Difficulty formatting datetime xaxis |
Posted by H?kan Elmqvist on Nov-30-2011 01:13 |
|
I have real time data coming from two different MySql-sources with different number of samples. The data is grouped by the hour and the xdata is formatted as unix_timestamp. I have two problems:
1) I would like to see the xlabels as whole hours.
2) I would like to put the xaxis labels at an angle.
My problems can be seen at http://sundsvik.dnsalias.org
For the xaxis I only use:
$c->xAxis->setLabelFormat("{value|d/m hh:nn}");
$c->xAxis->setTickDensity(30);
The xdata is supplied in the following way:
...
$levellayer->setXData($tu);
...
$eurlayer->setXData($tup);
....
Any tip will be appreciated
H?kan |
Re: Difficulty formatting datetime xaxis |
Posted by Peter Kwan on Dec-01-2011 01:45 |
|
Hi H?kan,
For your case, please use:
$levellayer->setXData(array_map(chartTime2, $tu));
...
$eurlayer->setXData(array_map(chartTime2, $tup));
....
$c->xAxis->setDateScale3("{value|d/m hh:nn}");
The chartTime2 function above is a ChartDirector function to change the unix timestamps into a format understood by ChartDirector. The setDateScale3 explicitly tell ChartDirector that the axis should be treated as a date/time axis, so that ChartDirector will place the labels at "natural date/time units" (such as at multiple of hours).
Hope this can help.
Regards
Peter Kwan |
Re: Difficulty formatting datetime xaxis |
Posted by H?kan Elmqvist on Dec-01-2011 21:06 |
|
Hello Peter
Thanks for your help.
I regret, however, to say that it was unnecessary. I had made the fundamental mistake of assuming that (unix_timestamp div 3600) resulted in whole hours, something that mixed up my xaxis data.
Changing my grouping argument to DATE_FORMAT(timestamp,'%Y-%m-%d %H') did the trick.
Sorry about that but thanks anyhow
H?kan |
|