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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.