简体   繁体   English

kendoui饼图的汇总函数

[英]kendoui aggregate function for pie chart

I'm trying to make pie chart with aggregate function. 我正在尝试使用聚合函数制作饼图。 It should display category name and products count in that category. 它应显示类别名称和该类别中的产品计数。 I don't know how to find product count for categories. 我不知道如何查找类别的产品计数。

How to find them? 如何找到他们? Thanks. 谢谢。

 var dataSource = new kendo.data.DataSource({ type: "odata", transport: { read: "//demos.telerik.com/kendo-ui/service/Northwind.svc/Categories" }, }); $("#chart").kendoChart({ dataSource: dataSource, legend: { visible: true }, seriesDefaults: { type: "pie" }, series: [{ field: "CategoryID", //it should be product count by category categoryField: "CategoryName", explodeField: "explode", labels: { visible: true, } }], }); 
 <div id="chart"></div> 

Try it this way, 这样尝试

    var dataSource = new kendo.data.DataSource({
        type: "odata",
        transport: {
            read: "//demos.telerik.com/kendo-ui/service/Northwind.svc/Categories?$expand=Products"
        },
    });


   $("#chart").kendoChart({
        dataSource: dataSource,
        legend: {
            visible: true
        },
        series: [{
            type: "pie",
            field: "Products.results.length",
            categoryField: "CategoryName",
            explodeField: "explode",
            labels: {
                visible: true,
            }
        }]
    });

Read up on odata expand and getting count of scalar navigation properties for further finesse 阅读有关odata expand的信息,并获取标量导航属性的计数,以进一步了解细节

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

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