I, like many others, have been suffering with too many labels on the X-axis
(especially for date/time based data).
Feel free to comment on the workaround below which suits my needs. The data
are date/time against values and depending on the 'depth' (i.e. number of
hours back) of data I've elected to only pull a selection of the date/time
values into the $data array, turning the rest into spaces.
My criteria are:
1 hour = labels each minute
1-6 hours = labels each 10th minute
6-24 hours = labels each hour
24 hours = labels each 6th hour
So far that has worked for the graph I want to produce, typically 24-72 hours
wide, drilling down to 1 hour sometimes.
FYI, there is a short script in the PHPlot "contrib" directory called
"prune_labels" which does something like this. However, it is simplistic, and
probably would not work well with date/time labels. Given the maximum number
of labels you want along the X axis (M), it zaps (M-1) out of every M from
your data array.
Depending on how your database records store the timestamps (assuming they are
not pre-formatted into the database as strings), another approach would be to
make those the X values (not labels) in integer form. I think you do that in
MySQL using the UNIX_TIMESTAMP function. Then you can let PHPlot format them
as date/times, and your X tick increment determines the label density.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I, like many others, have been suffering with too many labels on the X-axis
(especially for date/time based data).
Feel free to comment on the workaround below which suits my needs. The data
are date/time against values and depending on the 'depth' (i.e. number of
hours back) of data I've elected to only pull a selection of the date/time
values into the $data array, turning the rest into spaces.
My criteria are:
1 hour = labels each minute
1-6 hours = labels each 10th minute
6-24 hours = labels each hour
So far that has worked for the graph I want to produce, typically 24-72 hours
wide, drilling down to 1 hour sometimes.
DT field is in the form "YYYY/MM/DD hh:mm:ss"
Hope that's of use to someone.
Thanks for posting that.
FYI, there is a short script in the PHPlot "contrib" directory called
"prune_labels" which does something like this. However, it is simplistic, and
probably would not work well with date/time labels. Given the maximum number
of labels you want along the X axis (M), it zaps (M-1) out of every M from
your data array.
Depending on how your database records store the timestamps (assuming they are
not pre-formatted into the database as strings), another approach would be to
make those the X values (not labels) in integer form. I think you do that in
MySQL using the UNIX_TIMESTAMP function. Then you can let PHPlot format them
as date/times, and your X tick increment determines the label density.