Donut Inner Text

怎甘沉沦 提交于 2019-12-22 12:57:07

问题


I developed a donut chart using highchart library. I need to include a label in the inner part of the donut.

Expected Result:

JS:

$(function () {
    $('#container8').highcharts({
        chart: {
            type: 'pie',
            options3d: {
                enabled: false,
                alpha: 0
            }
        },
        colors: ['#081969', '#0e2569', '#1e3b81', '#284893', '#30509b'],
        title: {
            text: ''
        },tooltip: {
            enabled: false
        },
        plotOptions: {
            pie: {
                innerSize: 140,
                depth: 45
            }
        },
        series: [{
            name: 'Delivered amount',
            data: [
                ['56%', 56],
                ['44%', 44]
            ]
        }]
    });
});

Fiddle can be found here: http://jsfiddle.net/ak9jK/


回答1:


title: {
        style: {
            fontSize: '48px',
            fontWeight: 'bold'
        },
        verticalAlign: 'middle'
    },

AND at the end

},

function (chart) {
    chart.setTitle({
        text: chart.series[0].data[0].y + '%'
    });
});

DEMO: http://jsfiddle.net/ak9jK/1/

Related questions:
Highcharts Donut Chart text in center change on hover
Place text in center of pie chart - Highcharts




回答2:


You can use Renderer which allows to add custom text.



来源:https://stackoverflow.com/questions/23491344/donut-inner-text

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!