JavaScript
var dataArray = [{
ErrorDate: "2017-09-07",
Brand: "Toyota",
Count: 3
}, {
ErrorDate: "2017-09-02",
Brand: "Ford",
Count: 258
}, {
ErrorDate: "2017-09-03",
Brand: "Ford",
Count: 239
}, {
ErrorDate: "2017-09-04",
Brand: "Ford",
Count: 197
}, {
ErrorDate: "2017-09-05",
Brand: "Ford",
Count: 187
}, {
ErrorDate: "2017-09-06",
Brand: "Ford",
Count: 418
}, {
ErrorDate: "2017-09-07",
Brand: "Ford",
Count: 344
}, {
ErrorDate: "2017-09-03",
Brand: "Mercedes",
Count: 43
}, {
ErrorDate: "2017-09-04",
Brand: "Mercedes",
Count: 220
}, {
ErrorDate: "2017-09-03",
Brand: "Chrysler",
Count: 3
}, {
ErrorDate: "2017-09-04",
Brand: "Chrysler",
Count: 3
}, {
ErrorDate: "2017-09-06",
Brand: "Chrysler",
Count: 6
}, {
ErrorDate: "2017-09-07",
Brand: "Chrysler",
Count: 1
}, {
ErrorDate: "2017-09-04",
Brand: "ford",
Count: 22
}, {
ErrorDate: "2017-09-06",
Brand: "ford",
Count:25
}, {
ErrorDate: "2017-09-07",
Brand: "ford",
Count: 63
}];
var chart = Highcharts.chart('container', {
chart: {
type: 'spline'
},
title: {
text: 'Car Metrix Test'
},
subtitle: {
text: 'Irregular time data in Highcharts JS'
},
xAxis: {
type: 'datetime',
dateTimeLabelFormats: { // don't display the dummy year
month: '%e. %b',
year: '%b'
},
title: {
text: 'Date'
}
},
yAxis: {
title: {
text: 'Count'
},
min: 0
},
tooltip: {
headerFormat: '<b>{series.name}</b><br>'
},
plotOptions: {
spline: {
marker: {
enabled: true
},
pointInterval: 24 * 3600 * 1000,
// pointStart: Date.parse("2017-09-02")
}
},
series: []
});
var seriesArr = [];
dataArray.forEach(function(point) {
var newPoint = [new Date(point.ErrorDate).getTime(), point.Count],
seriesIndex = seriesArr.findIndex((series) => series.name === point.Brand);
if (seriesIndex === -1) {
seriesArr.push({
name:...