我需要显示多个与相同数据相关的饼图.因此,我希望他们都成为同一个图表的一部分,并将它们作为单独的系列实现.
在我尝试将标签/标题放在每个饼图上之前,这一切都没有问题.似乎我只能拥有整个集团的头衔.见jsfiddle
有没有办法让每个图表上的标题?
See above jsfiddle for example
Run Code Online (Sandbox Code Playgroud)
我遇到了同样的问题,并通过highcharts支持论坛找到了该解决方案:http ://highcharts.uservoice.com/forums/55896-general/suggestions/3073133-pie-title
Highcharts花花公子已经编写了一个插件,您可以看到它在以下jsfiddle上工作:http : //jsfiddle.net/highcharts/tnSRA/
我已将该插件复制粘贴到我包含在我的网站中的highcharts-plugins.js文件中,它的工作原理很吸引人!
这是插件代码:
/**
* Pie title plugin
* Last revision: 2012-12-21
*/
(function (Highcharts) {
Highcharts.wrap(Highcharts.seriesTypes.pie.prototype, 'render', function (proceed) {
var chart = this.chart,
center = this.center || (this.yAxis && this.yAxis.center),
titleOption = this.options.title,
box;
proceed.call(this);
if (center && titleOption) {
box = {
x: chart.plotLeft + center[0] - 0.5 * center[2],
y: chart.plotTop + center[1] - 0.5 * center[2],
width: center[2],
height: center[2]
};
if (!this.title) {
this.title = this.chart.renderer.label(titleOption.text)
.css(titleOption.style)
.add()
.align(titleOption, null, box);
} else {
this.title.align(titleOption, null, box);
}
}
});
}(Highcharts));
Run Code Online (Sandbox Code Playgroud)
这就是配置标题的方式(将其放入系列元素中):
title: {
// align: 'left',
// x: 0
// style: { color: XXX, fontStyle: etc }
text: '<b>Pie 1</b><br>Subtext',
verticalAlign: 'top',
y: -40
},
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7267 次 |
| 最近记录: |