Socket
Socket
Sign inDemoInstall

chartjs-plugin-boxselect

Package Overview
Dependencies
6
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    chartjs-plugin-boxselect

Chart.js plugin to select points on a chart with a click-and-drag box


Version published
Weekly downloads
184
decreased by-5.64%
Maintainers
1
Install size
5.49 MB
Created
Weekly downloads
 

Readme

Source

chartjs-plugin-boxselect

A Chart.js plugin to select points using click-and-drag boxes.
Works with scatter and line chart types.

Installation

To install with npm

npm install --save chartjs-plugin-boxselect

To use with a <script> tag

<script src="https://cdn.jsdelivr.net/npm/chart.js@2.9.4/dist/Chart.bundle.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/chartjs-plugin-boxselect"></script>

Configuration

To configure the box-select plugin, add a new config option to a chart config.

plugins: {
    boxselect: {
        select: {
            enabled: true,
            direction: 'xy'
        },
        callbacks: {
            beforeSelect: function(startX, endX, startY, endY) {
                // return false to cancel selection
                return true;
            }
            afterSelect: function(startX, endX, startY, endY, datasets) {

            }
        }
    },
}

Options

The direction setting defines which box shapes can be drawn. The options are x, xy, or y. The default is xy.

The datasets parameter in the afterSelect callback is the same size as the array of datasets in the chart.
Each dataset has the parameters data, labels, and indexes.
data contains an array of points that fell inside the selection box.
indexes contains the corresponding index of each point that was selected from the original dataset.data labels contains the labels (if any) from the dataset that correspond to the selected points.

Samples

A sample chart that shows how the afterSelect callback can be used to highlight data is in the /samples directory.

Development

rollup is required to build.
The built boxselect.js file is in the /dist directory.
The build command is npm run build.

Credits

Created by Thomas Humphries.
Code inspired by chartjs-plugin-crosshair and chartjs-plugin-zoom.

Licence

chartjs-plugin-boxselect.js is available under the MIT licence.

Keywords

FAQs

Last updated on 29 Jan 2021

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc