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 微信小程序 用oss下载 aliyun-oss-sdk-6.18.0.min client报错
  • ¥15 ArcGIS批量裁剪
  • ¥15 labview程序设计
  • ¥15 为什么在配置Linux系统的时候执行脚本总是出现E: Failed to fetch http:L/cn.archive.ubuntu.com
  • ¥15 Cloudreve保存用户组存储空间大小时报错
  • ¥15 伪标签为什么不能作为弱监督语义分割的结果?
  • ¥15 编一个判断一个区间范围内的数字的个位数的立方和是否等于其本身的程序在输入第1组数据后卡住了(语言-c语言)
  • ¥15 游戏盾如何溯源服务器真实ip?
  • ¥15 Mac版Fiddler Everywhere4.0.1提示强制更新
  • ¥15 android 集成sentry上报时报错。