Highcharts返回错误14 [英] Highcharts returning error 14
问题描述
这是我的
gateway_useage:function(usage_data){
var options = {
图表:{
renderTo:'gateway-usage',
plotBackgroundColor:null,
plotBorderWidth:null,
plotShadow:false
},
title:{text:'Gateway Usage'},
tooltip:{
pointFormat:'{series.name}:< b> {point.percentage}%< / b>',
percentDecimals:1
},
plotOptions:{
pie:{
allowPointSelect:true,
cursor:'pointer',
dataLabels:{
enabled:true,
color:'#000000',
connectorColor:'#000000',
formatter:function(){
返回'< b>'+ this.point.name +'< / b>:'+ this.percentage +'%';
}
},
showInLegend:true
}
},
series:[{
type:'pie',
名称:'用法',
}]
}
var serie1 = usage_data.map(函数(e){
return [例如, val];
});
options.series.push({data:serie1});
var chart = new Highcharts.Chart(options);
$ / code>
在加载页面并检查错误控制台并显示Uncaught Highcharts错误#14:www.highcharts.com/errors/14。什么是做错了,请帮助我
发送到series.data的字符串值,期望Number
如果你传入一个字符串作为数据点,它会发生。
数据点是yValue,如果你的 serie .data
的格式为
[y1,y2,y2]
或
[[ x1,y1],[x2,y2],[x3,y3]]
或
[
{x:x1,y:y1},
{x:x2,y:y2},
{x:x3,y:y3}
]
上述形式存储在 y1
, y2
& y3
应该是数字。您可以使用 parseFloat()
来实现此目的。或在JavaScript中 parseInt()
var serie1 = usage_data.map(function(e){
return [egateway,parseFloat(e.val)];
});
或者在您使用的服务器技术中执行此操作
In(PHP 4> = 4.2.0,PHP 5) floatval()
可以使用
$ float_value_of_var = floatval(123.456);
Am trying to draw a pie chart with highcharts, after spending hours trying to figure out how process a JSON string into a javascript array. This is what i have
gateway_useage: function(usage_data) {
var options = {
chart: {
renderTo:'gateway-usage',
plotBackgroundColor: null,
plotBorderWidth: null,
plotShadow: false
},
title: { text: 'Gateway Usage' },
tooltip: {
pointFormat: '{series.name}: <b>{point.percentage}%</b>',
percentageDecimals: 1
},
plotOptions: {
pie: {
allowPointSelect: true,
cursor: 'pointer',
dataLabels: {
enabled: true,
color: '#000000',
connectorColor: '#000000',
formatter: function() {
return '<b>'+ this.point.name +'</b>: '+ this.percentage +' %';
}
},
showInLegend: true
}
},
series: [{
type: 'pie',
name: 'Usage',
}]
}
var serie1 = usage_data.map( function(e) {
return [e.gateway, e.val];
});
options.series.push({data: serie1});
var chart = new Highcharts.Chart(options);
}
After loading the page and checking the error console saying "Uncaught Highcharts error #14: www.highcharts.com/errors/14 ". What am doing wrong, please help me out
Highcharts Error #14 clearly says
String value sent to series.data, expected Number his happens if you pass in a string as a data point
data point is the yValue, if your serie.data
is of the form
[y1,y2,y2]
or
[[x1,y1],[x2,y2],[x3,y3]]
or
[
{ x : x1 ,y : y1 },
{ x : x2 ,y : y2 },
{ x : x3 ,y : y3 }
]
In any of the above forms the type of data stored in y1
,y2
& y3
should be numeric. You can achieve this my simply using the parseFloat()
or parseInt()
in javascript
var serie1 = usage_data.map( function(e) {
return [e.gateway, parseFloat(e.val)];
});
or do it in the server technology that you are using
In (PHP 4 >= 4.2.0, PHP 5) floatval()
can be used
$float_value_of_var = floatval("123.456");
这篇关于Highcharts返回错误14的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!