我使用Highchart来显示MySQL数据库中的数据。
它可以正确显示图表中的数据。但时间显示为一年。像这样:Full data
但是当我想只查看最后一个数据时,它会显示正确的时间格式(毫秒:&%;%H:%M:%S')但行和数据消失{{3 }}
这是我的图表:
chart = new Highcharts.stockChart({
chart: {
renderTo : 'container',
type: 'spline',
events: {
load: function () {
this.setTitle(null, {
text: 'Built chart in ' + (new Date() - start) + 'ms'
});
}
}
},
xAxis: {
type: 'datetime',
dateTimeLabelFormats: { // don't display the dummy year
second: '%H:%M:%S'
},
title: {
text: 'Date'
}
},
yAxis: {
opposite: false,
title: {
text: 'Temperature (°C)'
}
},
subtitle: {
text: 'Built chart in ...' // dummy text to reserve space for dynamic subtitle
},
series: [{
name: 'Temperature',
data: (function () {
// generate an array of random data
var data = [];
for (var i = 0; i <= NbRow; i ++) {
data.push([
date_array[i],
temp_array[i]
]);
}
return data;
}()),
marker: {
enabled: true,
radius: 2
},
//pointStart: date_array[0],
//pointInterval: 30000,
tooltip: {
valueDecimals: 2,
valueSuffix: '°C'
}
}]
});
}); }
temp_array是我的温度数组 date_array是UNIX milisecond格式的本地日期。
我尝试更改dateLabelFormat或添加rangeSelector。但没有任何改变。
编辑:这是我的完整MYSQL表。
748 1521546599000 27.30
749 1521546629000 27.31
750 1521546659000 27.28
751 1521546689000 27.26
752 1521546719000 27.29
753 1521546750000 27.31
754 1521546780000 27.25
755 1521546810000 27.26
756 1521546817000 27.25
757 1521546847000 27.30
758 1521546878000 27.29
759 1521546908000 27.33
760 1521546938000 27.40
761 1521546968000 27.42
762 1521546998000 27.43
763 1521547029000 27.44
764 1521547059000 27.43
765 1521547089000 27.44
766 1521547119000 27.42
767 1521547149000 27.47
768 1521547180000 27.46
769 1521547210000 27.46
770 1521547240000 27.48
771 1521547270000 27.50
772 1521547301000 27.52
773 1521547331000 27.54
774 1521547361000 27.54
775 1521547391000 27.58
776 1521547421000 27.60
777 1521547452000 27.59
778 1521547482000 27.61
779 1521547512000 27.62
780 1521547542000 27.63
781 1521547572000 27.62
782 1521547603000 27.63
783 1521547633000 27.63
784 1521547663000 27.63
785 1521547693000 27.63
786 1521547723000 27.64
787 1521547747000 27.64
788 1521547777000 27.68
789 1521547807000 27.67
790 1521547838000 27.67
791 1521547868000 27.67
792 1521547898000 27.65
793 1521547928000 27.65
794 1521547955000 27.66
795 1521547985000 27.67
796 1521548024000 27.68
797 1521548054000 27.67
798 1521548084000 27.64
799 1521548115000 27.64
800 1521548145000 27.65
801 1521554209000 26.17
802 1521554239000 26.21
803 1521554269000 26.23
804 1521554299000 26.27
805 1521554316000 26.26
806 1521554346000 26.28
807 1521554354000 26.26
808 1521554384000 26.29
809 1521554414000 26.28
810 1521554445000 26.30
811 1521554475000 26.29
812 1521554505000 26.29
813 1521554535000 26.30
814 1521554565000 26.30
815 1521554596000 26.33
816 1521554626000 26.34
817 1521554656000 26.35
818 1521554686000 26.33
819 1521554716000 26.36
820 1521554747000 26.40
821 1521554777000 26.44
822 1521554807000 26.42
823 1521554837000 26.35
824 1521554868000 26.35
825 1521554898000 26.37
826 1521554928000 26.40
827 1521554958000 26.41
828 1521554988000 26.41
829 1521555019000 26.40
830 1521555049000 26.38
831 1521555079000 26.37
832 1521555109000 26.37
833 1521555139000 26.41
834 1521555170000 26.42
835 1521555200000 26.38
836 1521555230000 26.35
837 1521555260000 26.35
838 1521555291000 26.35
839 1521555321000 26.32
840 1521555351000 26.30
841 1521555381000 26.31
842 1521555411000 26.31
843 1521555442000 26.33
844 1521555472000 26.39
845 1521555502000 26.41
846 1521555532000 26.40
847 1521555562000 26.41
848 1521555593000 26.44
849 1521555623000 26.46
850 1521555653000 26.46
851 1521555683000 26.46
852 1521555713000 26.45
853 1521555744000 26.44
854 1521555774000 26.49
855 1521555804000 26.53
856 1521555834000 26.54
857 1521555864000 26.56
858 1521555895000 26.57
859 1521555925000 26.55
860 1521555955000 26.54
861 1521555985000 26.55
862 1521556016000 26.55
863 1521556046000 26.53
864 1521556076000 26.54
865 1521556106000 26.53
866 1521556136000 26.55
867 1521556167000 26.58
868 1521556197000 26.55
869 1521556227000 26.52
870 1521556257000 26.43
871 1521556287000 26.39
872 1521556318000 26.36
&#13;