我正在使用此图表以以下格式显示通过RestService获取的数据:
"jsonData": [
{
"Resource": "ABC",
"TimeStamp": "23-07-2017",
"StatusPercentage": 100
},
{
"Resource": "PQR",
"TimeStamp": "23-07-2017",
"StatusPercentage": 100
},
{
"Resource": "XYZ",
"TimeStamp": "23-07-2017",
"StatusPercentage": 50
},
{
"Resource": "ABC",
"TimeStamp": "24-07-2017",
"StatusPercentage": 100
},
{
"Resource": "PQR",
"TimeStamp": "24-07-2017",
"StatusPercentage": 50
},
{
"Resource": "XYZ",
"TimeStamp": "24-07-2017",
"StatusPercentage": 100
}]
我将以下内容转换为highcharts的这种格式:
类别:[23-07-2017,24-07-2017]
系列:[{名称:ABC,数据:[100,100]},{名称:PQR,数据:[100,50]},{名称:XYZ,数据:[50,100]}]
Highcharts.chart('container', {
title: {
text: 'Solar Employment Growth by Sector, 2010-2016'
},
subtitle: {
text: 'Source: thesolarfoundation.com'
},
yAxis: {
title: {
text: 'Number of Employees'
}
},
legend: {
layout: 'vertical',
align: 'right',
verticalAlign: 'middle'
},
plotOptions: {
series: {
pointStart: 2017
}
},
series: series: [ {
name: 'ABC',
data: [100,50,70],
timestamp: '23-07-2017'
}, {
name: 'XYZ',
data: [50,100,100],
timestamp: '24-07-2017'
}]
});
如何在此JS小提琴中将pointstart设置为特定于日期,特定于月份或特定年份:http://jsfiddle.net/bfhu7suv/
如Pointstart:6月或Pointstart:星期五或Pointstart:2017年7月23日
最佳答案
加:
xAxis: {
type: 'datetime'
},
系列可以写为:
series: [{
name: 'Project Development',
data: [
null,
null,
[Date.UTC(2013, 5, 3), 12169],
[Date.UTC(2013, 5, 4), 11269]
]
}, {
name: 'Other',
data: [
[Date.UTC(2013, 5, 1), 12908],
[Date.UTC(2013, 5, 2), 12908],
[Date.UTC(2013, 5, 3), 2908],
[Date.UTC(2013, 5, 4), 2208]
]
}]
和PlotOptions起点为:
plotOptions: {
series: {
pointStart: Date.UTC(2013, 4, 30)
}
},
演示Fiddle