我有一个数据数组,其中包含带有两个字段的对象,它们分别是 date_time 和 sale_quantity 。在我的数据源中,我将 date_time 类型明确设置为 date 。
当我更改 date_time (ASC / DESC)的排序时,它不会更改结果图表。
var dataSource = new kendo.data.DataSource({
data: [
{"date_time": "2018-09-15T11:20:07.85", "sale_quantity": 1.000},
{"date_time": "2018-09-15T12:50:33.41", "sale_quantity": 3.000},
{"date_time": "2018-09-15T12:53:12.85", "sale_quantity": 3.000},
{"date_time": "2018-09-15T12:54:30.27", "sale_quantity": 2.000},
{"date_time": "2018-09-15T14:59:48.76", "sale_quantity": 3.000},
{"date_time": "2018-09-03T11:25:30.16", "sale_quantity": 1.000},
{"date_time": "2018-08-30T11:43:48.36", "sale_quantity": 1.000},
{"date_time": "2018-08-30T10:50:29.71", "sale_quantity": 1.000},
{"date_time": "2018-08-30T10:43:02.60", "sale_quantity": 1.000},
{"date_time": "2018-08-30T10:20:57.38", "sale_quantity": 1.000},
{"date_time": "2018-08-29T15:28:45.01", "sale_quantity": 1.000},
{"date_time": "2018-08-29T11:22:40.04", "sale_quantity": 1.000},
{"date_time": "2018-08-28T10:05:00.28", "sale_quantity": 1.000}
],
schema: {
model: {
fields: {
date_time: { type: "date" }
}
}
},
sort: {
field: "date_time",
dir: "asc" // DOESN'T SEEM TO AFFECT RESULTING CHART
}
});
$("#chart").kendoChart({
dataSource: dataSource,
title: {
text: "Past 6 Weeks Sales"
},
categoryAxis: {
labels: {
dateFormats: {
weeks: "Week dd/MM"
}
},
baseUnit: "weeks"
},
seriesDefaults: {
type: "column",
labels: {
visible: true,
background: "transparent"
}
},
series: [{
field: "sale_quantity",
categoryField: "date_time",
aggregate: "sum"
}]
});
我已经设置了完全相同的数据源,并将其与网格一起使用,并且排序工作正常。我不知道为什么它适用于网格而不适用于图表。