简体   繁体   English

将饼图名称显示为标题

[英]Show Pie Chart Name as Title

Is there a way to show the pie chart name on top, bottom, right or left of a pie chart without having to use the labels, like they use in this highcharts demo: 有没有一种方法可以在饼图的顶部,底部,右侧或左侧显示饼图名称,而不必像在 highcharts演示中使用的标签那样使用标签:

        labels: {
            items: [{
                html: '<b>Total fruit consumption<b>',
                style: {
                    left: '40px',
                    top: '8px',
                    color: 'black'
                }
            }]
        }

The labels have an absolute position in pixels, and for the pies I am using percentages. 标签具有以像素为单位的绝对位置,对于馅饼,我使用百分比。
When there is a resizing, the labels stay on the same place and the pies move, and I can't get the same relative position in percentage for both. 调整大小时,标签会停留在相同的位置,而饼子也会移动,而我无法以百分比形式获得相同的相对位置。 Example pie: 饼图示例:

{ data: [{ color: '#31B7C9', name: 'Slice 1', y: 1266364.92333333 }, { color: '#9ED93E', name: 'Slice 2', y: 7284620.73 }, { color: '#DABF12', name: 'Slice 4', y: 2330663.39333333 }], name: 'Pie Chart Name', type: 'pie', center: ["25%", "25%"], showInLegend: true, size: "20%", dataLabels: { enabled: false }}

Any idea how to get the pie chart name to display as its title? 知道如何获取饼图名称以显示其标题吗?

Example in jsFiddle here . 此处的 jsFiddle中的示例。

Thank you in advance 先感谢您

EDIT: So it looks like you want to have the same chart as in the demo and not just a pie chart. 编辑:所以看起来您想拥有与演示中相同的图表,而不仅仅是饼图。 If that is the case my answer below fails. 如果是这种情况,我在下面的回答将失败。 You will need to use labels and position them. 您将需要使用标签并放置它们。

----Keeping below code for future reference--- ----保留以下代码以供将来参考-

Yes, Use the title property. 是的,使用标题属性。 Example here: http://jsfiddle.net/wergeld/svkmM/ 此处的示例: http : //jsfiddle.net/wergeld/svkmM/

title: {
    text: 'A Title!'
}

我找到了一个插件,可以在此处显示饼图标题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM