E
E
entermix2016-02-05 19:55:36
PHP
entermix, 2016-02-05 19:55:36

How to correctly populate an array for C3JS?

I want to build a chart using C3JS (let's say it's a product sales chart) for this you need an array, for example:

['2013-01-01', '2013-01-02', '2013-01-03', '2013-01-04', '2013-01-05', '2013-01-06', '2013-01-07', '2013-01-08', '2013-01-09', '2013-01-10', '2013-01-11', '2013-01-12'],


As you can see, the array contains all dates from 2013-01-01' to 2013-01-12, but what if for example 2013-01-03' there were no sales? By a query from the database, we get grouped (by date) data (number), but there are no days without sales, how to correctly fill the array with zeros for those days when sales were not made? Trite to go through the cycle and add missed days?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Mikhail Beloshitsky, 2016-02-08
@mbeloshitsky

c3.js handles datasets with gaps in the time axis quite well (see jsfiddle for example ).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question