Highchart散点未连接

时间:2014-08-12 07:42:10

标签: highcharts

我已将lineWidth设置为让每个点相互连接,但它仍然不起作用。请帮我检查下面的示例数据以及选项设置

[{"x":101.4,"y":69.235,"marker":{"fillColor":"#BF0B23"}},{"x":101.23,"y":69.24},{"x":101.03,"y":69.24},{"x":100.82,"y":69.22},{"x":100.61,"y":69.21},{"x":100.41,"y":69.21},{"x":99.95,"y":69.19},{"x":99.96,"y":69.19},{"x":100,"y":69.14},{"x":100.03,"y":69.1},{"x":100.04,"y":69.1},{"x":100.09,"y":69.085},{"x":100.15,"y":69.08},{"x":100.08,"y":69.135},{"x":100.03,"y":69.095},{"x":100.06,"y":69.07},{"x":100.1,"y":69.07},{"x":100.25,"y":69.045},{"x":100.18,"y":69.105},{"x":102.82,"y":68.925},{"x":102.52,"y":68.89},{"x":102.2,"y":68.86},{"x":102.18,"y":68.87},{"x":102.25,"y":68.855},{"x":102.21,"y":68.845},{"x":102.82,"y":69.595},{"x":102.9,"y":69.575},{"x":102.86,"y":69.595},{"x":102.8,"y":69.775},{"x":102.83,"y":69.695},{"x":102.83,"y":69.755},{"x":102.82,"y":69.615},{"x":102.91,"y":69.615},{"x":102.88,"y":69.575},{"x":102.98,"y":69.585},{"x":103.16,"y":69.655},{"x":103,"y":69.655},{"x":102.91,"y":69.595},{"x":102.82,"y":69.595},{"x":102.7,"y":69.575},{"x":102.76,"y":69.625},{"x":102.77,"y":69.575},{"x":102.76,"y":69.545},{"x":102.85,"y":69.505},{"x":102.99,"y":69.505},{"x":103.02,"y":69.505},{"x":102.88,"y":69.515},{"x":103,"y":69.845},{"x":103.19,"y":69.805},{"x":103.1,"y":69.725},{"x":102.79,"y":69.675},{"x":102.96,"y":69.735},{"x":103.14,"y":69.625},{"x":103.02,"y":69.615},{"x":103.27,"y":69.785},{"x":103.19,"y":69.765},{"x":102.88,"y":69.475},{"x":103,"y":69.475},{"x":102.99,"y":69.395},{"x":99.49,"y":69.195},{"x":99.32,"y":69.215,"marker":{"fillColor":"black"}}]

这不是整个数据。这些数据不适合SO textarea

选项

options = {
    chart: {
        type: 'scatter',
        animation:false             
    },              
    plotOptions: {
        scatter: {
            turboThreshold: 9999
        }                   
    },              
    series: [{
        name: 'Hysteresis',
        data: [],
        lineWidth: 2
    }]
}

这里我尝试使用jsFiddle并且它正在运行。但是为了您的信息,我会像chart.series[0].setData()那样动态加载数据并且它无法正常工作

console.log($('ele').highcharts());

的屏幕截图

enter image description here

enter image description here

这是我尝试的替代方案,如何在启动highcharts之前将数据推送到系列

options.series[0].data.push({
    x: parseFloat(model.get('xreading')), 
    y: parseFloat(model.get('yreading')), 
    marker:{ fillColor: '#BF0B23', symbol: 'triangle' }, label: model.get('iv_date')
});

任何可能阻止它划线的选项

2 个答案:

答案 0 :(得分:0)

在未连接时解决这个小问题,

  • 检查您的数据。如果正常推送阵列
  • ,请确保x和y可用
  • 不适合你,为什么不尝试构建json字符串然后解析它

那是所有人

答案 1 :(得分:-1)

散点图(definition of a scatter plot @ Wikipedia)没有连接每个数据点的线。折线图有一行:Highcharts, Basic Line @ highcharts.com

变化:

type: 'scatter',

type: 'line',

然后相应地更改plotOptions

也许您真正想要的是趋势线?请参阅:https://github.com/virtualstaticvoid/highcharts_trendline 这是一个regression line,它会自动计算以适合您的数据吗?