Made a line chart using chart.js, took data from json. But in the end only 1 line is drawn and all the data goes there, and the rest lines just repeat it. 
$(document).ready(function() { $.ajax({ url: 'http://localhost:3000/second.json', success: function(json) { var data = []; var MONTHS = []; var city = []; for (index = 0; index < json.data.length; ++index) { if (json.data[index]['graphId'] == 1) { for (i = 0; i < json.data[index]['values'].length; ++i) { data.push(json.data[index]['values'][i]['value']); MONTHS.push(json.data[index]['values'][i]['x']); city.push(json.data[index]['values'][i]['y']); } } } var ctx = document.getElementById("linechart"); var myChart = Chart.Line(ctx, { type: 'line', data: { labels: MONTHS, datasets: [{ label: 'Владивосток', backgroundColor: [ 'rgba(255,255,255,0)' ], borderColor: [ 'rgb(31, 119, 180)' ], data: data, }, { label:'Дальнийвосток', backgroundColor: [ 'rgba(255,255,255,0)' ], borderColor: [ 'rgb(255, 127, 14)' ], data: data } , { label:'Дирекция Приволжский', backgroundColor: [ 'rgba(255,255,255,0)' ], borderColor: [ 'rgb(44, 160, 44)' ], data: data } , { label:'Краснодар', backgroundColor: [ 'rgba(255,255,255,0)' ], borderColor: [ 'rgb(214, 39, 40)' ], data: data } , { label:'Москва', backgroundColor: [ 'rgba(255,255,255,0)' ], borderColor: [ 'rgb(148, 103, 189)' ], data: data } ] }, }); } }); }); Initially through the city wanted, but there is just 1 line with all the names
and the data is in my format
"values":[ { "x":"01 (28-MAR-19-03-APR-19)", "y":"ДАЛЬНИЙВОСТОК", "value":3.85 }, { "x":"01 (28-MAR-19-03-APR-19)", "y":"ДИРЕКЦИЯ ПРИВОЛЖСКИЙ", "value":308.58 }, { "x":"01 (28-MAR-19-03-APR-19)", "y":"КРАСНОДАР", "value":7.7 }, { "x":"01 (28-MAR-19-03-APR-19)", "y":"МОСКВА", "value":7.01 }, { "x":"02 (21-MAR-19-27-MAR-19)", "y":"ВЛАДИВОСТОК", "value":6.21 }, { "x":"02 (21-MAR-19-27-MAR-19)", "y":"ДАЛЬНИЙВОСТОК", "value":2.87 }, { "x":"02 (21-MAR-19-27-MAR-19)", "y":"ДИРЕКЦИЯ ПРИВОЛЖСКИЙ", "value":4.39 }, { "x":"02 (21-MAR-19-27-MAR-19)", "y":"КРАСНОДАР", "value":6.81 },