2012-01-09 88 views
6

如何缩小KendoUI饼图的大小?我正在使用以下配置的饼图。我已将边距设置为1像素,并将填充设置为1像素,但对饼图的呈现方式似乎没有任何影响。我没有冠军,但仍有空间可以冠军。我希望能够缩小图表顶部和图例与实际图表之间的空间。如何缩小KendoUI饼图的大小?

我的配置:

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 } 
     }); 
+0

你能分享一下您的JSON数据?也许只有一条线? – 2012-01-20 16:52:34

回答

17

饼图具有60像素padding默认。如果您需要减少饼图周围的空间,则需要更改该填充。

... 
series: [{ 
    type: "pie", 
    field: "percentage", 
    categoryField: "source", 
    explodeField: "explode", 
    padding: 0 
}] 
... 
+0

认真,谢谢! – zeroflaw 2017-10-25 05:35:02

2
$("#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)#" 
    } 

}); 

这里我们定义在chartarea来调整饼图的属性..