Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to reduce the size of the KendoUI Pie Chart?

How do you reduce the size of the KendoUI pie chart? I am using the pie chart using the following configuration. I have set the margins to 1 pixel and the padding to 1 pixel but it doesn't appear to have any affect on how the pie chart is rendered. I have no title but there is still space for a title. I want to be able to reduce the space between the top of the chart and the space between the legend and the actual chart.

My configuration:

jQuery("#chart").kendoChart({
//              theme: jQuery(document).data("kendoSkin") || "Metro",
            legend: {
                position: "bottom",
                padding: 1,
                margin: 1
            },
            seriesDefaults: {
                labels: {
                    visible: true,
                    template: "${ value }%"
                }
            },
            dataSource: {
                data: <%=ChartData%>
            },
            series: [{
                type: "pie",
                field: "percentage",
                categoryField: "source",
                explodeField: "explode"
            }],
            tooltip: {
                visible: false,
                template: "${ category } - ${ value }%"
            },
            title: { padding: 1, margin: 1 },
            seriesColors: ["#d15400", "#19277e", "#e2935e", "#d2d2d2"],
            chartArea: { margin: 1 },
            plotArea: { margin: 1 }
        });
like image 202
Rodney Hickman Avatar asked Jan 09 '12 16:01

Rodney Hickman


People also ask

What is Kendo chart?

The Kendo UI Chart uses modern browser technologies to render high-quality data visualizations. All graphics are rendered on the client by using Scalable Vector Graphics (SVG) with a fallback to Canvas. The Charts support a set of series types such as Bar, Line, Area, Bullet, Pie, Scatter, Bubble, Polar, and other.


2 Answers

The pie chart has 60px padding by default. If you need to reduce that space around the pie chart you need to change that padding.

...
series: [{
    type: "pie",
    field: "percentage",
    categoryField: "source",
    explodeField: "explode",
    padding: 0
}]
...
like image 100
gudman Avatar answered Sep 24 '22 15:09

gudman


$("#chart").kendoChart({
    theme: $(document).data("kendoSkin") || "default",
    title: {
        text: "Samplet"
    },
    seriesDefaults: {
        labels: {
            template: "#= kendo.format('{0:P}', percentage)#",
            visible: true
        }
    },chartArea: {
    width: 300,
    height: 300
},
    series: [{
        type: "pie",
        data: [{
            category: "Quality",
            value: 80},
        {
            category: "Time",
            value: 20},
        {
            category: "Cost",
            value: 40}]}],
    tooltip: {
        visible: true,
        template: "#= kendo.format('{0:P}', percentage)#"
    }

});

here we define a property in chartarea to resize the pie chart..

like image 37
Sankar Avatar answered Sep 25 '22 15:09

Sankar