dqwh1219 2018-08-13 03:46
浏览 98
已采纳

如何为Highcharts同步图表设置xData作为日期(Y-M)?

I want to plot the synchronized charts like this https://www.highcharts.com/demo/synchronized-charts. The JSON data will come from SQL database and the xData (x-axis) looks like below which are in year-month format:

xData: [
  "2004-04","2004-04","2004-04","2004-04","2004-04","2004-04","2004-04",
  "2004-04","2004-04","2004-04","2004-04","2012-08","2004-04","2004-04","2004-04",  
  "2004-04","2004-04","2004-04","2004-04","2004-04","2004-04","2004-04","2004-04",  
  "2004-04","2004-04","2004-04","2004-04","2004-04","2013-12","2004-04","2004-04",  
  "2007-11","2007-11","2012-08","2005-05","2004-04","2004-04","2004-04","2004-04",  
  "2004-04","2004-04","2004-04","2016-04","2004-04","2012-08","2004-04","2004-04",  
  "2004-04","2004-04","2004-04","2004-04","2004-04","2005-05","2004-04","2004-04",
  "2012-08","2016-04","2004-04","2004-04","2004-04","2004-04","2012-08","2004-04",  
  "2004-04","2004-04","2004-04","2012-08","2004-04","2004-04","2004-04","2004-04",
  "2004-04","2006-02","2007-11","2004-04","2004-04","2004-04","2005-05","2004-04",
  "2004-04","2005-05","2004-04","2004-04","2012-08","2012-08","2006-02","2005-05",
  "2004-04","2016-04","2004-04","2004-04","2004-04","2006-02","2004-04","2004-04",
  "2004-04","2004-04","2004-04","2005-05","2007-11"
 ]

So, how to plot those data as x-axis for synchronized charts?

  • 写回答

1条回答 默认 最新

  • doufei1893 2018-08-13 05:16
    关注

    you could simply use that one array as the labels for the xAxis:

    xAxis: {
        labels: {
            format: '{value}'
        }
    },
    

    but in order to plot on a timeline axis, you may need to convert these strings into integer values, which can be done with PHP: strtotime($date.'-01 00:00:00') ...hint: you need to multiply the result (in seconds) with 1000 for JavaScript timestamps (in milliseconds).

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog