【问题标题】:Highcharts while collecting JSON and changing the date by modifying the pointstartHighcharts 同时收集 JSON 并通过修改 pointstart 更改日期
【发布时间】:2017-07-27 08:51:00
【问题描述】:

我正在使用此图表以这种格式显示我通过 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 :June 或 Pointstart: Friday 或 Pointstart: 23-Jul-2017

【问题讨论】:

    标签: javascript angularjs highcharts


    【解决方案1】:

    添加:

     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

    【讨论】:

    猜你喜欢
    • 2013-09-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-11-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-09-23
    相关资源
    最近更新 更多