我使用了剑道平移和缩放演示,并且缩放工作正常,但是当我尝试平移图表时,只清除所有数据。
我正在使用远程数据
这里我使用数据源调用远程数据:
var dataSource = new kendo.data.DataSource({
transport: {
read: {
url: "/Home/GetActivities",
dataType: "json",
type: "POST"
}
},
group: "Group",
pageSize: viewSize,
page: 0
});
拖动句柄和其他变量:
//Maximum/Minimum number of visible items
var Min_Size = 5;
var Max_Size = 15;
//Minimum distance in px to start dragging
var Drag_Thr = 50;
//State variables
var viewStart = 0;
var viewSize = Min_Size;
var newStart;
function onDrag(e) {
var chart = e.sender;
var ds = chart.dataSource;
var delta = Math.round(e.originalEvent.x.initialDelta / Drag_Thr);
if (delta != 0) {
newStart = Math.max(0, viewStart - delta);
newStart = Math.min(dataSource.length - viewSize, newStart);
ds.query({
skip: newStart,
page: 0,
pageSize: viewSize
});
}
}
function onDragEnd() {
viewStart = newStart;
}
最后是我的图表:
$("#chart").kendoChart({
theme: 'Metro',
title: { text: 'Activities' },
dataSource: dataSource,
legend: { visible: true, position: "top" },
series: [{ field: "Total", labels: { format: "{0}%", visible: true }, spacing: 0 }],
valueAxis: { labels: { format: "{0}%" }, line: { visible: false }, max: 100, min: 0 },
categoryAxis: { field: "Description", name: "Description", majorGridLines: { visible: false }, labels: { rotation: -90 } },
tooltip: { visible: false },
drag: onDrag,
dragEnd: onDragEnd,
zoom: onZoom
});
我不确定出了什么问题,导致拖动清除图表数据。
提前感谢您的帮助