Highstock highcharts 不规则数据得到错误的 x 尺度 [英] Highstock highcharts irregular data gets wrong x-scale

查看:39
本文介绍了Highstock highcharts 不规则数据得到错误的 x 尺度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有不规则的数据.当我使用 highcharts 时,图表绘制得很好:

I have irregular data. Chart draws well when I use highcharts:

$(function() {
  var chart = new Highcharts.Chart({
    chart: {
      renderTo: 'chart'
  },
  xAxis: {
    type: 'datetime'
  },
  series: [{
    name: 'Volume',
    data: chart_arr,
  }]
});
});

http://jsfiddle.net/KnTaw/9/

但我有很多数据,所以我需要放大日期并选择highstock.然后奇怪的事情发生了:x 轴变成了非线性.

But I have a lot of data so I need to zoom on the date and choose highstock. Then a strange thing happens: the x-axis become non-linear.

$(function() {
  var chart2 = new Highcharts.StockChart({
    chart: {
      renderTo: 'chart2'
    },
    rangeSelector: {
      selected: 0
    },
    xAxis: {
      type: 'datetime'
    },
    series: [{
      name: 'val',
      data: chart_arr,
      type : 'area',
    }]
  });
});

http://jsfiddle.net/Mc3mW/1/

请注意,1 月 6 日 20:00-20:30 半小时范围内的数据比 1 月 11-13 日 2 天分配的空间更多.(当然数据是一样的.)

Please note that the data for half an hour range Jan 6 20:00-20:30 allocates more space than 2 days Jan 11-13. (Of course the data is the same.)

如何强制 highstock 处的 x 轴变为线性?或者如何为 highcharts 启用底部缩放工具?谢谢.

How can I force x-axis at highstock to become linear? Or How can I enable a bottom zoom tool for highcharts? Thank you.

推荐答案

您需要设置xAxis.ordinal 属性设置为 false,默认为 true.True 值表示点应以固定间隔放置 w.r.t space (pixels),而 False 将点更改为以固定间隔放置 w.r.t.时间

You will need to set the xAxis.ordinal property to false, this is true by default. True value indicates the points should be placed at fixed intervals w.r.t space (pixels), and False changes points to be placed at fixed intervals w.r.t. time

xAxis: {       
    ordinal: false
}

线性 x 轴 |Highstock@jsFiddle

这篇关于Highstock highcharts 不规则数据得到错误的 x 尺度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆