JSFiddle - React, Tailwind, and code Playground
by Ignacio Fuentes
HTML
<link rel="stylesheet" href="http://cdn.kendostatic.com/2013.2.918/styles/kendo.common.min.css">
<script src="http://cdn.kendostatic.com/2013.2.918/js/kendo.all.min.js"></script>
<link rel="stylesheet" href="http://cdn.kendostatic.com/2013.2.918/styles/kendo.silver.min.css">
<script src="http://demos.kendoui.com/content/shared/js/people.js"></script>
<button id="zoomin">+</button>
<br />
<button id="zoomout">-</button>
<div id="chart"></div>
JavaScript
var ds = new kendo.data.DataSource({
schema: {
model: {
id: "id",
fields: {
time: {},
distance: {
type: "number" //this is the type
}
}
}
},
data: [{
id: "1",
time: 0,
distance: 0
}, {
id: "2",
time: 1,
distance: 1
}, {
id: "3",
time: 2,
distance: 4
}, {
id: "4",
time: 3,
distance: 9
}, {
id: "5",
time: 4,
distance: 16
}, {
id: "6",
time: 5,
distance: 25
}, {
id: "7",
time: 6,
distance: 36
}, ]
});
var chart = $("#chart").kendoChart({
dataSource: ds,
seriesDefaults: {
type: "line"
},
series: [{
field: "distance",
name: "Distance",
categoryField: "time",
}]
}).data("kendoChart");
$("#zoomin").click(function () {
var ds = chart.dataSource;
ds.filter(getFilter(0, 10));
});
$("#zoomout").click(function () {
var ds = chart.dataSource;
ds.filter(getFilter(0, 40));
});
function getFilter(start, length) {
return [{
field: "distance",
operator: "gte",
value: start
}, {
field: "distance",
operator: "lte",
value: start + length
}]
}