# Zoom

Integration with chartjs-plugin-zoom (opens new window)

const config = {
  type: 'line',
  data: data,
  options: {
    scales: {
      x: {
        type: 'realtime',
        realtime: {
          duration: 20000,
          refresh: 1000,
          delay: 2000,
          onRefresh: onRefresh
        }
      },
      y: {
        title: {
          display: true,
          text: 'Value'
        }
      }
    },
    interaction: {
      intersect: false
    },
    plugins: {
      zoom: {
        pan: {
          enabled: true,
          mode: 'x'
        },
        zoom: {
          pinch: {
            enabled: true
          },
          wheel: {
            enabled: true
          },
          mode: 'x'
        },
        limits: {
          x: {
            minDelay: 0,
            maxDelay: 4000,
            minDuration: 1000,
            maxDuration: 20000
          }
        }
      }
    }
  }
};

For plain JavaScript, use script tags in the following order.

<script src="path/to/chartjs/dist/chart.min.js"></script>
<script src="path/to/luxon/dist/luxon.min.js"></script>
<script src="path/to/chartjs-adapter-luxon/dist/chartjs-adapter-luxon.min.js"></script>
<script src="path/to/chartjs-plugin-annotation/dist/chartjs-plugin-zoom.min.js"></script>
<script src="path/to/chartjs-plugin-streaming/dist/chartjs-plugin-streaming.min.js"></script>

For bundlers, import and register modules to the chart.

import {Chart} from 'chart.js';
import 'chartjs-adapter-luxon';
import ZoomPlugin from 'chartjs-plugin-zoom';
import StreamingPlugin from 'chartjs-plugin-streaming';
Chart.register(ZoomPlugin, StreamingPlugin);