0.0.18 • Published 3 years ago

chartjs-plugin-ruler v0.0.18

Weekly downloads
21
License
MIT
Repository
gitlab
Last release
3 years ago

chartjs-plugin-ruler

npm version

This plugins adds the possiblity to add rulers into the chart. When the calculate button is clicked a callback is called with the x-axis value for each ruler.

NOTE: This plugin is highly specific for one application and I do NOT recommend using it.

example image

Installation

You can install the plugin using the npm:

npm install chartjs-plugin-ruler

Usage

Example code on how to use this plugin:

import Chart from 'chart.js'
import RulerPlugin from 'chartjs-plugin-ruler'

// Register plugin
Chart.plugins.register(RulerPlugin)

// Plugin options
const options = {
    plugins: {
        ruler: {
            rulers: {
                '1': {
                    buttonClass: 'btn btn-danger',
                    innerHtml: 'ruler1',
                    innerHtmlRemove: 'remove1',
                    color: 'red'
                },
                '2': {
                    buttonClass: 'btn btn-primary',
                    innerHtml: 'ruler2',
                    innerHtmlRemove: 'remove2',
                    color: 'blue'
                },
                '3': {
                    buttonClass: 'btn btn-success',
                    innerHtml: 'ruler3',
                    innerHtmlRemove: 'remove3',
                    color: 'green'
                }
            },
            calculateButton: {
                buttonClass: 'btn btn-info',
                innerHtml: 'calculate'
            },
            onCalculate: function(data){
                console.log(data)
            },
            onRulersChange: function(data){
                console.log(data)
            }
        }
    }
}

// Create Chart as usual
... 
0.0.17

3 years ago

0.0.18

3 years ago

0.0.16

3 years ago

0.0.15

4 years ago

0.0.13

4 years ago

0.0.14

4 years ago

0.0.12

4 years ago

0.0.11

4 years ago

0.0.10

4 years ago

0.0.9

4 years ago

0.0.8

4 years ago

0.0.7

4 years ago

0.0.6

4 years ago

0.0.5

4 years ago

0.0.4

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago