Edit this page

Maintain Pan and Zoom State on Rebind

Normally, the Kendo UI Chart resets the axis range after the data source fetches new data. If users pan or zoom the Chart, they will see the initial viewport after the new data is loaded.

The example below demonstrates how to store and load the axis range. Changes are detected in the drag and zoom events. The axis range is restored in the databound event.

    <button id="rebind">Rebind Chart</button>
    <div id="chart"></div>
      // Sample data
      var data = [];
      for (var i = 0; i < 100; i++) {
        var val = Math.round(Math.random() * 10);
          category: "C" + i,
          value: val

      function createChart() {
        var axisMin = 0;
        var axisMax = 10;

        function updateRange(e) {
          var axis = e.sender.getAxis('axis')
          var range = axis.range()
          axisMin = range.min;
          axisMax = range.max;

        function restoreRange(e) {
          e.sender.options.categoryAxis.min = axisMin;
          e.sender.options.categoryAxis.max = axisMax;

          renderAs: "canvas",
          dataSource: {
            data: data
          categoryAxis: {
            name: "axis",
            min: axisMin,
            max: axisMax,
            labels: {
              rotation: "auto"
          series: [{
            type: "column",
            field: "value",
            categoryField: "category"
          pannable: {
            lock: "y"
          zoomable: {
            mousewheel: {
              lock: "y"
            selection: {
              lock: "y"
          zoom: updateRange,
          drag: updateRange,
          dataBound: restoreRange

      $("#rebind").click(function() {


See Also

For more runnable examples on Kendo UI Charts, browse the How To documentation folder.

Is this article helpful? Yes / No
Thank you for your feedback!

Give article feedback

Tell us how we can improve this article