I'm building a dashboard with anycharts. I get my data from mysql database in JSON format. Example of a query:
SELECT DATE( data_inscricao ) AS name, COUNT( id ) AS value FROM utilizador GROUP BY name
So, I'm getting a count of all users registered grouped by registration date.
Example result:
[{name: "2016-01-22",value: "7"}, {name: "2016-01-25", value: "3"}, {name: "2016-01-26", value: "1"}, {name: "2016-01-27", value: "2"}, {name: "2016-02-02", value: "1"}, ...
I'il like to show 0 (zero) for dates where there weren't any registrations, like 2016-01-23, 2016-01-24, 2016-01-28, ...
Is that possible?
Thanks
Firstly you need to define min and max values of dates. Then you can generate array with contains every day in period and merge it with values from database. In your case we have
2016-01-22
-2016-02-02
period:Here the
$array
is your array of DB. after this you'll get something like:I hope it will helpful for you!