Skip to content

Chartjs plugin which allows you to select a range of data by dragging over a chart

Notifications You must be signed in to change notification settings

01CodeLT/chartjs-plugin-selectdrag

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Chart JS Plugin Select Drag

Chartjs plugin which allows you to select a range of data by dragging over a chart, see example https://stackblitz.com/edit/chartjs-selectdrag?file=index.html

Usage

Register the plugin with chart js...

import Chart from "chart.js/auto";
import SelectDragPlugin from "@01coder/chartjs-plugin-selectdrag";
Chart.register(SelectDragPlugin);

Enable it in the settings of a chart

type: "bar",
options: {
  plugins: {
      selectdrag: {
          enabled: true,
          onSelectComplete: (event) => {
              // Show selected
              document.getElementById('results').innerHTML = event.range;

              // Get selected range
              console.log(event.range);
              
              // Get selection coordinates
              console.log(event.boundingBox);
          }
      }
  },
},
data: { 
    labels: [], 
    datasets: []
}

Please note: This package is yet to be fully reviewed and tested, furthermore changes need to be made for other charts and selection types...

About

Chartjs plugin which allows you to select a range of data by dragging over a chart

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages