Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

chartjs-plugin-zoom

Package Overview
Dependencies
Maintainers
4
Versions
39
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

chartjs-plugin-zoom

Plugin that enables zoom and pan functionality in Chart.js charts.

  • 2.2.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
154K
increased by2.49%
Maintainers
4
Weekly downloads
 
Created

What is chartjs-plugin-zoom?

The chartjs-plugin-zoom package is a plugin for Chart.js that enables zooming and panning functionalities for charts. It allows users to interact with charts by zooming in and out, as well as panning across the chart area to explore data in more detail.

What are chartjs-plugin-zoom's main functionalities?

Zooming

This feature allows users to zoom in and out of the chart using the mouse wheel or pinch gestures. The 'mode' option can be set to 'x', 'y', or 'xy' to control the zooming direction.

const chart = new Chart(ctx, {
  type: 'line',
  data: data,
  options: {
    plugins: {
      zoom: {
        zoom: {
          wheel: {
            enabled: true
          },
          pinch: {
            enabled: true
          },
          mode: 'xy'
        }
      }
    }
  }
});

Panning

This feature allows users to pan across the chart area by clicking and dragging. The 'mode' option can be set to 'x', 'y', or 'xy' to control the panning direction.

const chart = new Chart(ctx, {
  type: 'line',
  data: data,
  options: {
    plugins: {
      zoom: {
        pan: {
          enabled: true,
          mode: 'xy'
        }
      }
    }
  }
});

Reset Zoom

This feature allows users to reset the zoom level to the original state. A button can be added to the UI to trigger the resetZoom method.

const chart = new Chart(ctx, {
  type: 'line',
  data: data,
  options: {
    plugins: {
      zoom: {
        zoom: {
          wheel: {
            enabled: true
          },
          pinch: {
            enabled: true
          },
          mode: 'xy'
        }
      }
    }
  }
});

// Reset zoom button
const resetZoomButton = document.getElementById('resetZoom');
resetZoomButton.addEventListener('click', function() {
  chart.resetZoom();
});

Other packages similar to chartjs-plugin-zoom

FAQs

Package last updated on 26 Nov 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc