highcharts图表组件错误集合分析--转载--zzk的第一篇博客

highcharts图表组件错误集合分析--转载--zzk的第一篇博客

highcharts简介

highcharts是一款JavaScript统计图插件,很好用。

highcharts常见错误

错误一:

错误描述:

Highcharts Error #10
 
Can't plot zero or subzero values on a logarithmic axis
This error occurs in the following situations:
If a zero or subzero data value is added to a logarithmic axis
If the minimum of a logarithimic axis is set to 0 or less
If the threshold is set to 0 or less

错误含义阐述:

出现这个问题的原因有一下几种可能:

1、当我们设置了坐标轴xAxis或者yAxis的type为“logarithmic”对数轴类型的情况下,series内的data数据内存在0或者小于0的数据,但是最新版本的highcharts.js已经更正了这个bug。

$(function () {
    $('#container').highcharts({
        xAxis: {
            categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
        },
        yAxis: {
            type: 'logarithmic'
        },
        
        series: [{
            data: [0,-20,3,5,555,6,8,9,4,6,1,2]        
        }]
    });
});

2、坐标轴设置了type为“logarithmic”对数轴的情况下,还设置了坐标轴的min最小值<=0的情况,将会报出该错误,形如:

$(function () {
    $('#container').highcharts({
    
        xAxis: {
            categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
        },
        
        yAxis: {
            type: 'logarithmic',
            minorTickInterval: 'auto',
            min:0
        },
    
        series: [{
            data: [-1, 5, 3, 7, 40, 3]
        }]
    
    });
});

3、设置了图表数据的个数的上限值<=0,形如:

$(function () {
    $('#container').highcharts({
        chart: {
            type: 'area'
        },
        xAxis: {
            categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
        },       
        plotOptions: {
            series: {
                threshold: -1
            }
        },        
        series: [{
            data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4]        
        }]
    });
});

但是目前的最新本版highcharts.js没有这个问题了的。

错误二:

错误描述

Highcharts Error #12
Highcharts expects point configuration to be numbers or arrays in turbo mode

This error occurs if the series.data option contains object configurations and the number of points exceeds the turboThreshold. It can be fixed by either setting the turboThreshold option to a higher value, or changing your point configurations to numbers or arrays. See turboThreshold.

错误含义阐述:

这个错误的含义很明显,主要是由于数据点个数超出了默认设置plotOpions内设置的turboThreshold为1000的限制。解决办法就是讲这个数值设置更大或者设置为0表示不做限制。具体可见帖子:http://www.stepday.com/post/tie/?331

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值