Organize bar chart by date

0

Using the ChartJS , I am generating a bar graph comparing between the current and previous month, the day and amount of payment made. The problem is that the labels have a range of 1 to 31, the chart data does not correctly follow the values.

The code below

;var chartJS_w0 = new Chart(document.getElementById('w0').getContext('2d')).Bar({
    "labels":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31],
    "datasets":{
        "1":{"data":[1600.7500305176,1154.9299926758,6404.6300048828,1609.1199951172,1189.7799987793,386.72999572754,1110.3299942017,720.71999359131,1307.1999816895,12326.089944839,735.86999511719,2125.9599761963,17231.699935913,4276.4899749756,1115.2200012207,5191.6699905396,4281.6599273682,1750,5896.2799987793],

        "fillColor":"#b9ea45",
        "strokeColor":"#0d8cba",
        "highlightFill":"#2d11b2",
        "highlightStroke":"#b153de"},

        "2":{
            "data":[2458.1199874878,1400,679.55999755859,412.92999267578],

            "fillColor":"#d8d59a",
            "strokeColor":"#d2dcfe",
            "highlightFill":"#d4a021",
            "highlightStroke":"#2acbda"
        }
    }
}, {});

Generate chart:

However,itfeedsthechartcontinuously.Forexample:Theseconddatasethasthevalues

"data":[2458.1199874878,1400,679.55999755859,412.92999267578],

And should be pointed out on the labels:

"label":["1","2","5","6"]

And not 1,2,3,4

    
asked by anonymous 19.10.2015 / 20:36

1 answer

0

The solution was to go through the array array and check which days there was no payment recorded, assigning the value zero. So that the values were merged according to the payday:

"data":[2458.1199874878,1400, 0, 679.55999755859,412.92999267578 ,0,0,0,0,0,0.....]
    
20.10.2015 / 19:53