npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@interisk-software/chartjs-plugin-selectdata

v0.2.1

Published

Data Selectable for Chart.js

Readme

chartjs-plugin-selectdata

npm CI Coverage Maintainability

Data Selectable for Chart.js Chart.js

You can select a data in the graph and it comes into focus, emphasizing only the selected one and clicking on it disables the focus and makes the graph return to normal

This plugin requires Chart.js 2.7.0 or later.

:rocket: Installation

You can download the latest version of chartjs-plugin-selectdata from the GitHub releases.

To install via npm:

npm install @interisk-software/chartjs-plugin-selectdata --save

To install via yarn:

yarn add @interisk-software/chartjs-plugin-selectdata

To use CDN:

<script src="https://cdn.jsdelivr.net/npm/@interisk-software/chartjs-plugin-selectdata"></script>
<script src="https://unpkg.com/@interisk-software/chartjs-plugin-selectdata"></script>

:man_cartwheeling: Usage

chartjs-plugin-selectdata can be used with ES6 modules, plain JavaScript and module loaders.

Include Chart.js and chartjs-plugin-selectdata.js in your page, the plugin will already be enabled.

Along with the plugin is also added as 2 new event settings onSelect and onSelectClear

Usage in ES6 as Module

Nothing else than importing the module should be enough.


import 'chartjs-plugin-selectdata';
// or
import SelectionDataPlugin from 'chartjs-plugin-selectdata';

Chart.js plugin register

In es6 with modules it is necessary to import, in plain javascript the plugin is available via windown


//Chart.js v3.x.x
Chart.register(SelectionDataPlugin);

//Chart.js v2.x.x
Chart.plugins.register(SelectionDataPlugin);

:gear: Configuration

The plugin options can be changed at 2 different levels and with the following priority:

  • per chart: options.plugins.selectdata.*
  • globally: Chart.defaults.global.plugins.selectdata.*

All available options are listed below.

| Name | Type | Default | Description | ---- | ---- | ------- | ----------- | onSelect | function | undefined | A function that is called every time a dataset is selected. more... | onSelectClear | function | undefined | A function that is called every time a dataset is deselected and the graph returns to default.more...

:pushpin: Functions

With the callback functions you can perform actions based on the interactions with the graph.

var onSelect = function(dataSelection) {
    console.log(dataSelection)
};

var onSelectClear = function(dataSelection) {
    console.log('it is clean')
};

// ...
options: {
    plugins: {
        selectdata: {
            onSelect: onSelect,
            onSelectClear: onSelectClear
        }
    }
}
//...

dataSelection properties

| Name | Type | Description | ---- | ---- | ----------- | datasetIndex | number | index of the selected dataset. | index | number | label index based on selection

:bar_chart: Chart

Options available in the instance of the chart

| Name | Type | Parameters | Description | ---- | ---- | ------- | ----------- | clearSelection | function | none | This function when executed resets the selection state. | selectDataIndex | function | indexnumber, indexDataSetnumber | This function selects the dataset data according to the index and indexDataSet.

With the functions added in the chart instance you can programmatically execute the selection actions

var ctx = document.getElementById('myChart').getContext('2d');
var myChart = new Chart(ctx, {/* options */})

// ...

// Wait to chart render
setTimeout(function () {
    myChart.selectDataIndex(0) // Select firt dataset data
}, 3000)

// ...

setTimeout(function () {
    myChart.clearSelection() // clear selection
}, 10000)

//...

:hammer: Building

You first need to install node dependencies (requires Node.js):

npm install

The following commands will then be available from the repository root:

npm run sample           # build and run sample
npm run dev              # build and run development mode using sample
npm run build            # build dist files
npm run build:dev        # build and watch for changes
npm run test             # run all tests
npm run lint             # perform code linting
npm run package          # create an archive with dist files and samples
npm run bower            # create bower.json

:balance_scale: License

chartjs-plugin-selectdata is available under the MIT license.