在HighCharts饼图图例中的大总计 [英] Grand Totals in HighCharts Pie Chart Legend
问题描述
有没有办法让我在我的传奇的价值栏末尾获得总计?这里是我的传说在这里的代码,以及它分成两列的数据[]集名称和值的小提琴。
图例:{
启用:true,
布局:'vertical',
align:'right',
width:220,
verticalAlign :'top',
borderWidth:0,
useHTML:true,
labelFormatter:function(){
return'< div style =width:200px><< ; span style =float:left>'+ this.name +'< / span>< span style =float:right>'+ this.y +'%< / span>< / DIV>';
},
title:{
text:'Primary',
style:{
fontWeight:'bold'
}
}
}
id像这样的列
Data1 2
Data2 3
Data3 2
---
7
我需要做的是在该行下方添加虚线或优选实线,然后添加所有数据的总计值。这是我目前的小提琴。
http:// jsfiddle .net / hAnCr / 29 /
谢谢!
图表:{
您可以通过将总数追加到最后一个图例项目事件:{
load:function(event){
$('。highcharts-legend-item')。last()。append('< br />< div style =width :200px>< hr />< span style =float:left>总计< / span>< span style =float:right>'+ total +'< / span> ;< / div>')
}
}
}
小提琴此处。
Is there a way for me to get a grand total at the end of my value column in my legend? Here is the code for my legend right here as well as the fiddle wtih it broken into two columns for the name and value of the data[] set.
legend: {
enabled: true,
layout: 'vertical',
align: 'right',
width: 220,
verticalAlign: 'top',
borderWidth: 0,
useHTML: true,
labelFormatter: function() {
return '<div style="width:200px"><span style="float:left">' + this.name + '</span><span style="float:right">' + this.y + '%</span></div>';
},
title: {
text: 'Primary',
style: {
fontWeight: 'bold'
}
}
}
id like the column to be something like this
Data1 2
Data2 3
Data3 2
---
7
What I need to be able to do is add the dashed or preferrably solid line underneath that row and then the grand total of all of the data values. Here is my current fiddle.
thank you!
You could hack this in by appending the total to the last legend item.
chart: {
events: {
load: function(event) {
$('.highcharts-legend-item').last().append('<br/><div style="width:200px"><hr/> <span style="float:left"> Total </span><span style="float:right"> ' + total + '</span> </div>')
}
}
}
Fiddle here.
这篇关于在HighCharts饼图图例中的大总计的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!