有人可以在 highchart 中发布自定义聚合方法的示例吗?我想创建一个自定义聚合方法,使用工具提示将以下点分组为一个点?我有一个数组,其中包含以下数据 array1 :['apple',2,4,10,12.5] 我希望上面的数组用一个工具提示表示在一个分组点中,显示如下 apple no of apples : 2 分钟:4 最大:10 平均:12.5
问问题
1015 次
1 回答
1
我会处理数据以将其转换为 highcharts 识别的格式,然后将额外的数据添加到点对象。您可以在工具提示格式化程序函数中引用该额外数据:
$(function () {
var input = [['apple',2,4,10,12.5],
['pear',1,5,10,12],
['orange',3,4,10,13.5],
['grape',4,4,10,11.5]],
data = [],
categories = [];
for (i=0;i<input.length;i++) {
categories.push(input[i][0]);
data.push({x: i,
y: input[i][1],
myMin: input[i][2],
myMax: input[i][3],
myMean: input[i][4]});
}
$('#container').highcharts({
tooltip: {
formatter: function() {
return '<b>'+ this.x +'</b><br/>' +
'No. of ' + this.x + ': ' + this.y + '<br/>' +
'min : ' + this.point.myMin + '<br/>' +
'max : ' + this.point.myMax + '<br/>' +
'mean : ' + this.point.myMean;
}
},
xAxis: {
categories: categories
},
chart: {
marginRight: 50
},
series: [{
data: data
}]
});
});
于 2013-10-07T21:56:38.230 回答