# chart-zooming

> Line chart of monthly temperature anomalies with selection, mouse-wheel, pinch zoom and scrollbar.

**Framework:** javascript  **Component:** Chart  **Variant:** zooming

## Get this item

**If you are an agent, fetch the JSON.** Source is inlined, so one request is enough and no tooling is required:

```
GET https://ai.syncfusion.com/r/javascript/chart-zooming.json
```

**Install Package(s)**

```bash
npm install @syncfusion/ej2-charts
```

**Notes**

- Syncfusion release: 2026 Volume 3 (v35.1.37)
- The Syncfusion package is licensed. The composition in this file is source you own and edit. See https://ai.syncfusion.com/licensing.md

## Source files

### src/components/chart-zooming/chart.html

```html
<style>
    #control-container {
        padding: 0px !important;
    }

    #material-gradient-chart stop {
        stop-color: #00bdae;
    }

    #fabric-gradient-chart stop {
        stop-color: #4472c4;
    }

    #bootstrap-gradient-chart stop {
        stop-color: #a16ee5;
    }

    #bootstrap4-gradient-chart stop {
        stop-color: #a16ee5;
    }

    #fluent-gradient-chart stop {
        stop-color: #1AC9E6;
    }
    #fluent-dark-gradient-chart stop {
        stop-color: #1AC9E6;
    }

    #highcontrast-gradient-chart stop {
        stop-color: #79ECE4;
    }

    #tailwind-gradient-chart stop {
        stop-color: #5A61F6;
    }

    #tailwind3-gradient-chart stop {
        stop-color: #2F4074;
    }

    #bootstrap5-gradient-chart stop {
        stop-color: #FD7E14;
    }

    #material-dark-gradient-chart stop {
        stop-color: #9ECB08;
    }

    #fabric-dark-gradient-chart stop {
        stop-color: #4472c4;
    }

    #bootstrap-dark-gradient-chart stop {
        stop-color: #a16ee5;
    }

    #tailwind-dark-gradient-chart stop {
        stop-color: #8B5CF6;
    }

    #tailwind3-dark-gradient-chart stop {
        stop-color: #8029F1;
    }

    #bootstrap5-dark-gradient-chart stop {
        stop-color:  #FD7E14;
    }
    #material3-gradient-chart stop {
        stop-color: #6355C7;
    }

    #material3-dark-gradient-chart stop {
        stop-color: #4EAAFF;
    }

    #fluent2-gradient-chart stop {
        stop-color: #6200EE;
    }

    #fluent2-highcontrast-gradient-chart stop {
        stop-color: #9BB449;
    }

    #fluent2-dark-gradient-chart stop {
        stop-color: #9BB449;
    }

    .chart-gradient stop[offset="0"] {
        stop-opacity: 0.75;
    }

    .chart-gradient stop[offset="1"] {
        stop-opacity: 0;
    }

</style>
<div class="control-section">
    <div id="container" align='center'></div>
</div>
```

### src/components/chart-zooming/chart.ts

```typescript
import { Chart, LineSeries, Category, Legend, Tooltip, DataLabel, type ILoadedEventArgs, Highlight } from '@syncfusion/ej2-charts';
import { Browser } from '@syncfusion/ej2-base';
import { zoomingChartData } from '../datasource/chart-data';

Chart.Inject(LineSeries, Category, Legend, Tooltip, DataLabel, Highlight);

/**
 * Sample for line chart with zooming capability
 * Initializes chart within the pre-loaded HTML element from chart.html
 */
export function initZoomingChart(): void {
  const data = zoomingChartData[0];

  let chart: Chart = new Chart({
    //Initializing Primary X Axis
    primaryXAxis: {
      valueType: 'Category',
      majorGridLines: { width: 0 },
      edgeLabelPlacement: 'Shift'
    },

    //Initializing Primary Y Axis
    primaryYAxis: {
      title: 'Temperature (°C)',
      labelFormat: '{value}',
      rangePadding: 'None',
      lineStyle: { width: 0 },
      majorTickLines: { width: 0 },
      minorTickLines: { width: 0 }
    },

    chartArea: {
      border: {
        width: 0
      }
    },

    //Initializing Chart Series
    series: [
      {
        type: 'Line',
        dataSource: data.data,
        xName: 'month',
        yName: 'temp',
        name: 'Temperature',
        width: 2,
        marker: {
          visible: true,
          width: 10,
          height: 10,
          shape: 'Circle',
          isFilled: true
        }
      }
    ],

    //Initializing the tooltip
    tooltip: {
      enable: true,
      enableHighlight: true,
      header: '<b>Temperature</b>',
      format: '${point.x} : <b>${point.y}°C</b>'
    },

    width: Browser.isDevice ? '100%' : '75%',
    legendSettings: { enableHighlight: true },
    
    //Initializing Chart title
    title: data.title,
    subTitle: data.subTitle,

    //Zooming settings
    zoomSettings: {
      enableSelectionZooming: true,
      enableMouseWheelZooming: true,
      enablePinchZooming: true,
      mode: 'XY',
      toolbarItems: ['Zoom', 'ZoomIn', 'ZoomOut', 'Pan', 'Reset']
    },

    load: (_args: ILoadedEventArgs) => {
      // Load event handler
    }
  });
  chart.appendTo('#container');
}

```
