dqwh1219 2018-08-12 19: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-12 21: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 IBMP550小型机使用串口登录操作系统
  • ¥15 关于#python#的问题:现已知七自由度机器人的DH参数,利用DH参数求解机器人的逆运动学解目前使用的PSO算法
  • ¥15 发那科机器人与设备通讯配置
  • ¥15 Linux环境下openssl报错
  • ¥15 我在使用VS编译并执行之后,但是exe程序会报“无法定位程序输入点_kmpc_end_masked于动态链接库exe上“,请问这个问题有什么解决办法吗
  • ¥15 el-select光标位置问题
  • ¥15 单片机 TC277 PWM
  • ¥15 在更新角色衣服索引后,Sprite 并未正确显示更新的效果该如何去解决orz(标签-c#)
  • ¥15 VAE代码如何画混淆矩阵
  • ¥15 求遗传算法GAMS代码
手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部