Я строю график, используя библиотеку highcharts
Ссылка на документацию и компонент
https://www.highcharts.com/demo/line-basic
И все хорошо, работает.
Но highcharts путает даты, а именно выводит месяц на месяц вперёд.
Т.е. я подаю на вход дату значение с датой 30.11.2017, а highcharts выводит это значение за 30.12.2017
Вот рабочий пример. highcharts получил данные за ноябрь, вывел за декабрь но в ноябре нет 31 числа и...мы видим глюк в виде линии.
Все даты перед вами. Там только 1 декабря, а остальное ноябрь.
(Date.UTC)
http://jsfiddle.net/68dkbwyq/
В чем тут дело? Highcharts путает даты?
Вот весь код (лучше конечно смотреть на jsfiddle, но обычно по правилам я обязан писать код на форуме)
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/series-label.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>
<div id="container"></div>
<style type="text/css">
#container {
min-width: 310px;
max-width: 800px;
height: 400px;
margin: 0 auto
}
</style>
Highcharts.chart('container', {
title: {
text: 'Solar Employment Growth by Sector, 2010-2016'
},
xAxis: {type: 'datetime',title: {text: 'Дата и время'}},
subtitle: {
text: 'Source: thesolarfoundation.com'
},
yAxis: {
title: {
text: 'Number of Employees'
}
},
legend: {
layout: 'vertical',
align: 'right',
verticalAlign: 'middle'
},
plotOptions: {
series: {
label: {
connectorAllowed: false
},
pointStart: 2010
}
},
series:[{type: 'line',name: 'Graph value',data:[[Date.UTC(2017,11,30,0,00),9509.94],[Date.UTC(2017,11,30,0,30),9810.31],[Date.UTC(2017,11,30,1,00),10192.8],[Date.UTC(2017,11,30,1,30),10225.4],[Date.UTC(2017,11,30,2,00),10005.2],[Date.UTC(2017,11,30,2,30),9759.49],[Date.UTC(2017,11,30,3,00),9837.41],[Date.UTC(2017,11,30,3,30),10067.5],[Date.UTC(2017,11,30,4,00),10018.5],[Date.UTC(2017,11,30,4,30),10299.1],[Date.UTC(2017,11,30,5,00),10497.2],[Date.UTC(2017,11,30,5,30),10294.6],[Date.UTC(2017,11,30,6,00),10468.4],[Date.UTC(2017,11,30,6,30),10468.9],[Date.UTC(2017,11,30,7,00),10547.2],[Date.UTC(2017,11,30,7,30),10639.3],[Date.UTC(2017,11,30,8,00),10584.1],[Date.UTC(2017,11,30,8,30),10451.5],[Date.UTC(2017,11,30,9,00),10401.8],[Date.UTC(2017,11,30,9,30),10109.1],[Date.UTC(2017,11,30,10,00),10169.4],[Date.UTC(2017,11,30,10,30),10198.1],[Date.UTC(2017,11,30,11,00),10229.6],[Date.UTC(2017,11,30,11,30),10328.7],[Date.UTC(2017,11,30,12,00),10299.2],[Date.UTC(2017,11,30,12,30),10224.7],[Date.UTC(2017,11,30,13,00),10172.6],[Date.UTC(2017,11,30,13,30),9870.03],[Date.UTC(2017,11,30,14,00),9625.49],[Date.UTC(2017,11,30,14,30),9778.6],[Date.UTC(2017,11,30,15,00),9746.09],[Date.UTC(2017,11,30,15,30),9840.83],[Date.UTC(2017,11,30,16,00),9869.31],[Date.UTC(2017,11,30,16,30),9446.63],[Date.UTC(2017,11,30,17,00),9248.45],[Date.UTC(2017,11,30,17,30),9280.01],[Date.UTC(2017,11,30,18,00),9444.66],[Date.UTC(2017,11,30,18,30),9173.61],[Date.UTC(2017,11,30,19,00),9271.73],[Date.UTC(2017,11,30,19,30),9388.94],[Date.UTC(2017,11,30,20,00),9351.12],[Date.UTC(2017,11,30,20,30),9328],[Date.UTC(2017,11,30,21,00),9623.22],[Date.UTC(2017,11,30,21,30),9653.61],[Date.UTC(2017,11,30,22,00),9670.28],[Date.UTC(2017,11,30,22,30),9843.62],[Date.UTC(2017,11,30,23,00),9861.05],[Date.UTC(2017,11,30,23,30),9712.51],[Date.UTC(2017,12,01,0,00),9445.4],[Date.UTC(2017,12,01,0,30),9604.6],[Date.UTC(2017,12,01,1,00),9698.45],[Date.UTC(2017,12,01,1,30),9935.77],[Date.UTC(2017,12,01,2,00),9809],[Date.UTC(2017,12,01,2,30),10095.3],[Date.UTC(2017,12,01,3,00),9946.29],[Date.UTC(2017,12,01,3,30),10011.7],[Date.UTC(2017,12,01,4,00),9877.52],[Date.UTC(2017,12,01,4,30),9709.8],[Date.UTC(2017,12,01,5,00),9779.05],[Date.UTC(2017,12,01,5,30),9626.41],[Date.UTC(2017,12,01,6,00),9814.85],[Date.UTC(2017,12,01,6,30),9680.19],[Date.UTC(2017,12,01,7,00),9724.1],[Date.UTC(2017,12,01,7,30),9900.37],[Date.UTC(2017,12,01,8,00),9860.04],[Date.UTC(2017,12,01,8,30),9709.8],[Date.UTC(2017,12,01,9,00),9599.24],[Date.UTC(2017,12,01,9,30),9641.76],[Date.UTC(2017,12,01,10,00),9476.05],[Date.UTC(2017,12,01,10,30),9481.86],[Date.UTC(2017,12,01,11,00),9561.43],[Date.UTC(2017,12,01,11,30),9740.38],[Date.UTC(2017,12,01,12,00),9819.18],[Date.UTC(2017,12,01,12,30),9872.91],[Date.UTC(2017,12,01,13,00),10021.3],[Date.UTC(2017,12,01,13,30),9899.53],[Date.UTC(2017,12,01,14,00),9804.14],[Date.UTC(2017,12,01,14,30),9968.57],[Date.UTC(2017,12,01,15,00),9963.92],[Date.UTC(2017,12,01,15,30),10272.5],[Date.UTC(2017,12,01,16,00),10154.9],[Date.UTC(2017,12,01,16,30),10441],[Date.UTC(2017,12,01,17,00),10661.3],[Date.UTC(2017,12,01,17,30),10665.3],[Date.UTC(2017,12,01,18,00),10576.9],[Date.UTC(2017,12,01,18,30),10506.7],[Date.UTC(2017,12,01,18,42),10566.7]]}, ],
responsive: {
rules: [{
condition: {
maxWidth: 500
},
chartOptions: {
legend: {
layout: 'horizontal',
align: 'center',
verticalAlign: 'bottom'
}
}
}]
}
});