chartjs-plugin-dragzone
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

chartjs-plugin-dragzone

npm

A Chart.js plugin to provide drag area selection. Compatible with Chart.js v3 (>= v1.0.0)

Installation

Install package with npm:

npm install chartjs-plugin-dragzone --save

Usage

import { Chart } from 'chart.js';
import ChartDragzone from 'chartjs-plugin-dragzone';

// Register the plugin to all charts
Chart.register(ChartDragzone);

// OR only to specific charts:
new Chart(ctx, {
  plugins: [ChartDragzone],
  options: {
    // ...
  }
});

Add plugin options to chart configuration.

plugins: {
  dragzone: {
    // Color the drag area
    color: 'rgba(70,146,202,0.3)',

    // This function calls the selected data after the drag is completed.
    // It is stored for each dataset.
    onDragSelection: function (datasets, chart) {
      const datas = datasets[0];
      console.log('Selected data: ' + datas.length);
    }
  }
}

Package Sidebar

Install

npm i chartjs-plugin-dragzone

Weekly Downloads

2

Version

1.0.0

License

MIT

Unpacked Size

49.6 kB

Total Files

11

Last publish

Collaborators

  • leey0818