Highcharts错误15 [英] Highcharts error 15

查看:566
本文介绍了Highcharts错误15的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用highcharts来表示这些数据:

  [
{
name :c1,
data:[
[
-52587360000000,
2
],
[
-52590038400000,
1
],
[
-52611724800000,
1
],
[
-52622611200000,
1
],
[
-52655184000000,
1
],
[
-52663392000000,
2
],
[
-52855545600000,
2
]
]
},
{
name: c2,
data:[
[
-52587360000000,
2
],
[
-52590038400000,
1
],
[
-52611724800000,
1
],
[
-52622611200000,
1
],
[
-52655184000000,
1
],
[
-52663392000000,
2
],
[
-52855545600000,
2
]
]
},
{
名称:c3,
数据:[
[
-52587360000000,
2
],
[
-52590038400000,
1
] ,
[
-52611724800000,
1
],
[
-52622611200000,
1
],
[
-52655184000000,
1
],
[
-52663392000000,
2
],
[
-52855545600000
2



$ b $ $ $ $ $ $ $
$ b

这是我尝试的:

  container.highcharts({
title: {
text:姓名
},
xAxis:{
键入:'datetime',
dateTimeLabelFormats:{
month:'%e。 %b',
year:'%b'
}
},
yAxis:{
title:{
text:'Occurrence'
$ b plotLines:[{
value:0,
width:1,
color:'#808080'
}]
},
tooltip:{
valueSuffix:'Occurrence'
},
legend:{
layout:'vertical',
align:'right',
verticalAlign:'middle',
borderWidth:0
},
series:response //
});

图表显示不正确,如您所见:

,并在控制台中出现此错误:

 Highcharts error#15:www.highcharts.com/errors/15

我的错误是什么?

解决方案

正如链接的错误消息会告诉你:


Highcharts预计数据排序



当您尝试创建线序列或股票图表时,会发生这种情况,因为数据未按升序X顺序排序。出于性能原因,Highcharts不对数据进行排序,而是要求实施者预先对数据进行预先排序。


在您的案例中您的第一个系列的x值是:

  -52587360000000 
-52590038400000
-52611724800000
-52622611200000
-52655184000000
-52663392000000
-52855545600000

只要看前两个,很清楚 -52587360000000 是一个比 -52590038400000 更小(更负数) 。看起来你实际上已经对它们进行了反向排序。也就是说,最大的数字是第一个,然后他们变得越来越小(更负面)。



您必须更改系列中数据的顺序,以便最小的数字是第一个,然后这些值会增加。


i'm trying to represent these data using highcharts:

[
  {
    "name": "c1",
    "data": [
      [
        -52587360000000,
        2
      ],
      [
        -52590038400000,
        1
      ],
      [
        -52611724800000,
        1
      ],
      [
        -52622611200000,
        1
      ],
      [
        -52655184000000,
        1
      ],
      [
        -52663392000000,
        2
      ],
      [
        -52855545600000,
        2
      ]
    ]
  },
  {
    "name": "c2",
    "data": [
      [
        -52587360000000,
        2
      ],
      [
        -52590038400000,
        1
      ],
      [
        -52611724800000,
        1
      ],
      [
        -52622611200000,
        1
      ],
      [
        -52655184000000,
        1
      ],
      [
        -52663392000000,
        2
      ],
      [
        -52855545600000,
        2
      ]
    ]
  },
  {
    "name": "c3",
    "data": [
      [
        -52587360000000,
        2
      ],
      [
        -52590038400000,
        1
      ],
      [
        -52611724800000,
        1
      ],
      [
        -52622611200000,
        1
      ],
      [
        -52655184000000,
        1
      ],
      [
        -52663392000000,
        2
      ],
      [
        -52855545600000,
        2
      ]
    ]
  }
]

This is what i try:

container.highcharts({
    title: {
        text:"Name"
    },
    xAxis: {
        type: 'datetime',
        dateTimeLabelFormats: {
            month: '%e. %b',
            year: '%b'
        }
    },
    yAxis: {
        title: {
            text: 'Occurrence'
        },
        plotLines: [{
            value: 0,
            width: 1,
            color: '#808080'
        }]
    },
    tooltip: {
        valueSuffix: 'Occurrence'
    },
    legend: {
        layout: 'vertical',
        align: 'right',
        verticalAlign: 'middle',
        borderWidth: 0
    },
    series: response // 
});

The chart isn't shown correctly as you can see: and in console i get this error:

"Highcharts error #15: www.highcharts.com/errors/15"

what is my error?

解决方案

As the link in the error message will tell you:

Highcharts expects data to be sorted

This happens when you are trying to create a line series or a stock chart where the data is not sorted in ascending X order. For performance reasons, Highcharts does not sort the data, instead it is required that the implementer pre-sorts the data.

In your case the x-values in your first series are:

-52587360000000
-52590038400000
-52611724800000
-52622611200000
-52655184000000
-52663392000000
-52855545600000

Just looking at the first two it is clear that -52587360000000 is a smaller (more negative) number than -52590038400000. It appears that you have in fact reverse-sorted them. That is, the largest number is first, then they get increasingly smaller (more negative).

You will have to change the order of the data in the series so that the smallest number is first and then the values increase.

这篇关于Highcharts错误15的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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