var initialData = [{
"name": "sales",
pointStart: Date.parse('7/7/2017'),
pointInterval: 24 * 3600 * 1000,
tickInterval: 24 * 3600 * 1000,
data: [[Date.parse('8/7/2017'),222],[Date.parse('9/7/2017'),333],[Date.parse('11/7/2017'),333]]}];
var chart = new Highcharts.Chart({
chart: {
renderTo: 'container',
defaultSeriesType: 'area',
},
xAxis: {
type: 'datetime',
tickmarkPlacement: 'on',
showFirstLabel: true,
showLastLabel: true,
endOnTick: true,
// second: '%H:%M:%S',
dateTimeLabelFormats: {
day: '%d. %b',
month: '%b \'%y',
year: '%Y'
},
labels: {
formatter: function() {
return Highcharts.dateFormat('%d %b %Y', this.value);
}
}
//,tickInterval : null
},
yAxis: {
},
legend: {
enabled: true
},
plotOptions: {
area: {
fillOpacity: .5,
marker: {
radius: 4
},
stacking: 'normal'
}
},
series: initialData
});
<script src="http://code.highcharts.com/highcharts.src.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>
<div id="container" style="height: 400px"></div>
感謝您的答覆第一,但請我需要動態傳遞(變量) 這個數據假設我有這樣的數據([(「2017年8月7日」 ),222],[('9/7/2017'),333],[('11/7/2017'),333]]}])在json字符串中如何存儲它在數組變量,然後通過它將數據元素串聯起來。 –
您的數據示例不是JSON格式的固定語法:'[[「8/7/2017」,222],[「9/7/2017」,333],[「11/7/2017」,333] ]'。對於實時數據,您可以使用客戶端[link](http://www.highcharts.com/docs/working-with-data/live-data)的獲取請求以特定間隔從服務器獲取數據,如果您想要即時更新您的數據,您可以使用'series [x] .setData()'方法:[link](http://api.highcharts.com/highcharts/Series.setData)。 – stpoa
我已將您的數據格式從方便的問題提問 – Jigar7521