Skip to content
Advertisement

Show non-uniformly time-spaced samples from MySQL database on Google Line Chart by php query

I’m using a Line Chart of Google, I take data from a database of MySQL, to show points of some variables at different datetime. The sample time is 1 minute, but ocationally some points are loss (dont worry about the reason), so when I create de chart, the distance between two point is the same for 1 minute or 1 hour. I want to the horizontal space between samples be consistent with the time jump.

The Date selection and Query to generate chart are:

JavaScript

And the script:

JavaScript

The final idea is to select one day and to show data from this day, so the X axis should be 24 hours.

Real data with non uniform spaced data

How it is showed in chart

Advertisement

Answer

the reason the axis labels aren’t spaced properly is because they are being loaded into the chart as strings

to get desired result, you will need to use actual date objects

this may be as easy as making the following change…

surround date string with new Date(), here…

JavaScript
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement