Highstock highcharts不规则数据错误x-scale [英] Highstock highcharts irregular data gets wrong x-scale

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

问题描述

我有不规则的资料。使用 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分配更多空间比2天1月11-13。 (当然数据是相同的。)

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.)

如何强制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 值表示点应以固定间隔wrt 空格(像素) False 改变点以固定间隔wrt放置时间

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

Linear x-axis | Highstock @ jsFiddle

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

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