# Maintain the Pan and Zoom State of the Chart on Rebind

## Environment

<table>
 <tr>
  <td>Product</td>
  <td>Progress® Kendo UI® Chart for jQuery</td>
 </tr>
 <tr>
  <td>Operating System</td>
  <td>Windows 10 64bit</td>
 </tr>
 <tr>
  <td>Visual Studio Version</td>
  <td>Visual Studio 2017</td>
 </tr>
 <tr>
  <td>Preferred Language</td>
  <td>JavaScript</td>
 </tr>
</table>

## Description

How can I store and load the axis range on pan-and-zoom in the Chart?

## Solution

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 following example demonstrates how to store and load the axis range. Changes are detected in the [`drag`](https://www.telerik.com/kendo-jquery-ui/documentation/api/dataviz/ui/chart/events/drag) and [`zoom`](https://www.telerik.com/kendo-jquery-ui/documentation/api/dataviz/ui/chart/events/zoom) events. The axis range is restored in the [`databound` event](https://www.telerik.com/kendo-jquery-ui/documentation/api/dataviz/ui/chart/events/databound).

```dojo
    <button id="rebind">Rebind Chart</button>
    <div id="chart"></div>
    <script>
      // Sample data
      var data = [];
      for (var i = 0; i < 100; i++) {
        var val = Math.round(Math.random() * 10);
        data.push({
          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;
        }

        $("#chart").kendoChart({
          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() {
        $("#chart").data("kendoChart").dataSource.read();
      });

      $(document).ready(createChart);
    </script>
```

## See Also

* [Chart JavaScript API Reference](https://www.telerik.com/kendo-jquery-ui/documentation/api/dataviz/ui/chart)
* [Drawing API](https://www.telerik.com/kendo-jquery-ui/documentation/framework/drawing/overview)
* [Aggregate Data in Pie Charts](https://www.telerik.com/kendo-jquery-ui/documentation/knowledge-base/pie-chart-aggregates)
* [Draw on Scatter Plots Surface](https://www.telerik.com/kendo-jquery-ui/documentation/knowledge-base/draw-on-scatter-plots)
* [Expand Clickable Area of Points](https://www.telerik.com/kendo-jquery-ui/documentation/knowledge-base/expand-clickable-area)
