Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In Kendo UI DataViz, how do I place the labels inside the pie chart

Please refer to this example: http://jsfiddle.net/mcLEb/

jQuery("#grid").kendoChart(
    {
        theme: jQuery(document).data("kendoSkin") || "default",
        legend:
        {
            position: "bottom"
        },
        chartArea: {
            height: 200
        },
        seriesDefaults:
        {
            labels:
            {
                visible: true,
                format: "{0}%",
                font: "12px Arial",
                center: '5%'
            }
        },
        series: [{
            type: "pie",
            data:[70,20,10]
        }],
        tooltip:
        {
            visible: false,
            template: "${ category } - ${ value }%"
        },
        title: { padding: 1, margin: 1 },
        seriesColors: ["#d15400", "#d2d2d2","#01619e"],
        plotArea: { margin: { left: 50, right: 50 } },
    });

More clarification: Right now, the labels are located outside of the pie chart with an arrow pointing to their corresponding pie section. I want the labels themselves to be inside their corresponding pie section.

I am aware that a pie section could get smaller than the actual text inside of it, but I will handle that.

Thanks in advance!

like image 783
Brian Avatar asked Dec 09 '13 20:12

Brian


2 Answers

use the code below (set position as "center")

seriesDefaults:
    {
        labels:
        {                
            position: "center",
            visible: true,
            format: "{0}%",
            font: "12px Arial",
        }
    }
like image 179
Abiola Avatar answered Sep 21 '22 08:09

Abiola


The best way I have found to do this is using position insideEnd on the labels.

seriesDefaults:
    {
        labels:
        {                
            position: "insideEnd",
            visible: true,
            format: "{0}%",
            font: "12px Arial",
            center: '5%'
        }
    }

Another way that was less reliable was to use a negative distance property on the labels.

 seriesDefaults:
    {
        labels:
        {                
            distance: -10,
            visible: true,
            format: "{0}%",
            font: "12px Arial",
            center: '5%'
        }
    }
like image 38
Dodecapus Avatar answered Sep 21 '22 08:09

Dodecapus