I want to put this.total in the text of the title in center of pie chart. My code in: http://jsfiddle.net/Cp73s/2124/
我想将this.total放在饼图中心的标题文本中。我的代码:http://jsfiddle.net/Cp73s/2124/
title: {
text: 'I want to put this.total here',
align: 'center',
verticalAlign: 'middle'
},
2 个解决方案
#1
Calculate title
var total = 0
for (var i = 0, len = data.length; i < len; i++) {
total += data[i][1]
}
Add
title: {
text: total+'<br>AVISOS',
},
Centre title in pie chart
Refer to answer in How to center chart title position dynamically inside pie chart in highcharts
饼图中的中心标题请参阅如何在高图中的饼图内动态地将图表标题位置居中
#2
Set title.x
: http://jsfiddle.net/Cp73s/2127/
设置title.x:http://jsfiddle.net/Cp73s/2127/
Text is positioned relative to the chart, not to the pie, so since you have legend on the right side, you need to add extra space for x
. Of course, since your legend title can vary it will be a good idea to set fixed width for legendItem
.
文本相对于图表而不是饼图定位,因此,由于右侧有图例,因此需要为x添加额外的空间。当然,由于您的图例标题可能会有所不同,因此为legendItem设置固定宽度是个好主意。
#1
Calculate title
var total = 0
for (var i = 0, len = data.length; i < len; i++) {
total += data[i][1]
}
Add
title: {
text: total+'<br>AVISOS',
},
Centre title in pie chart
Refer to answer in How to center chart title position dynamically inside pie chart in highcharts
饼图中的中心标题请参阅如何在高图中的饼图内动态地将图表标题位置居中
#2
Set title.x
: http://jsfiddle.net/Cp73s/2127/
设置title.x:http://jsfiddle.net/Cp73s/2127/
Text is positioned relative to the chart, not to the pie, so since you have legend on the right side, you need to add extra space for x
. Of course, since your legend title can vary it will be a good idea to set fixed width for legendItem
.
文本相对于图表而不是饼图定位,因此,由于右侧有图例,因此需要为x添加额外的空间。当然,由于您的图例标题可能会有所不同,因此为legendItem设置固定宽度是个好主意。