【问题标题】:Highcharts Series data as JSON doesn't render作为 JSON 的 Highcharts 系列数据不呈现
【发布时间】:2016-10-20 16:31:31
【问题描述】:

我有一个“样条”HighChart 工作,但想向工具提示添加更多数据,因此希望使用带有 xy 语法的 JSON 对象来进一步填充此对象

最初我使用的系列格式为:

{
  name: 'Series 1',
  data: [[x,y],[x,y],[x,y]]
}

这很好,但是将其更改为:

{
  name: 'Series 1',
  data: [{x: xVal, y: yVal},{x: xVal, y: yVal},{x: xVal, y: yVal}]
}

已停止我的图表工作。在这里使用小提琴:https://jsfiddle.net/xbL65gqn/ 这种语法似乎是有效的。什么可能导致它无法工作?

我的 highcharts 配置供参考:

{
chart: {
  type: 'spline',
  backgroundColor: 'transparent',
  style: {
    color: FONT_COLOR
  }
},
credits: { enabled: false },
plotOptions: {
  series: {
    marker: { enabled: false }
  }
},
legend: { enabled: false },
series: series,
title: {
  text: '',
  labels: {
    style: {
      color: FONT_COLOR
    }
  }
},
tooltip: {
  crosshairs: {
    dashStyle: 'solid'
  }
},
xAxis: {
  type: 'datetime',
  labels: {
    style: {
      color: FONT_COLOR
    }
  }
},
yAxis: {
  title: {
    text: 'Uplift',
    textAlign: 'right',
    rotation: 0,
    style: {
      color: FONT_COLOR
    },
    y: -174,
    x: 34
  },
  max: maxLabel,
  min: -maxLabel,
  showLastLabel: false,
  labels: {
    formatter: function () {
      return this.value + '%'
    },
    style: {
      color: FONT_COLOR
    }
  }
}

【问题讨论】:

  • 您在图表中加载了多少点?如果超过1000,可能是turboThreshold引起的jsfiddle.net/xbL65gqn/1如果是turboThreshold引起的,设置为0禁用(0或者大于点数的值)

标签: javascript highcharts


【解决方案1】:

我自己解决了这个问题。在计算y 轴上的minmax 时,我使用系列数据通过获取seriesData[1]y 坐标)来查找它们,并且在将结构更改为JSON 对象

因此我在y 轴上的minmaxNaN

【讨论】:

    猜你喜欢
    • 2017-09-07
    • 2019-12-20
    • 1970-01-01
    • 2013-05-23
    • 2011-12-24
    • 2013-03-17
    • 2014-12-11
    • 1970-01-01
    • 2019-12-08
    相关资源
    最近更新 更多