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 🙏

© 2024 – Pkg Stats / Ryan Hefner

chartjs-plugin-style

v0.5.0

Published

Chart.js plugin for more styling options

Downloads

44,536

Readme

chartjs-plugin-style

npm Bower Travis Code Climate Awesome

Chart.js plugin for more styling options

This plugin requires Chart.js 2.6.0 or later.

Installation

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

To install via npm:

npm install chartjs-plugin-style --save

To install via bower:

bower install chartjs-plugin-style --save

To use CDN:

<script src="https://cdn.jsdelivr.net/npm/chartjs-plugin-style@latest/dist/chartjs-plugin-style.min.js"></script>
<script src="https://unpkg.com/chartjs-plugin-style@latest/dist/chartjs-plugin-style.min.js"></script>

Usage

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

chartjs-plugin-style requires Chart.js. Include Chart.js and chartjs-plugin-style.js to your page to enable style options.

Version 0.5 supports the bevel, drop shadow, inner glow, outer glow and overlay effects for datasets and the tooltip. More options are to be added in the upcoming releases.

Usage in ES6 as module

Nothing else than importing the module should be enough.

import 'chartjs-plugin-style';

Tutorial and Samples

You can find a tutorial and samples at nagix.github.io/chartjs-plugin-style.

Configuration

To configure this plugin, you can simply add the following properties to your datasets and tooltip. point* properties are used only in line, radar and scatter charts. hover* properties are not used in a tooptip.

| Name | Type | Scriptable | Indexable | Default | ---- | ---- | :--: | :--: | ---- | backgroundOverlayColor | Color | Yes | Yes | 'rgba(0, 0, 0, 0)' | backgroundOverlayMode | string | Yes | Yes | 'source-over' | bevelWidth | number | Yes | Yes | 0 | bevelHighlightColor | Color | Yes | Yes | 'rgba(0, 0, 0, 0)' | bevelShadowColor | Color | Yes | Yes | 'rgba(0, 0, 0, 0)' | hoverBackgroundOverlayColor | Color | Yes | Yes | 'rgba(0, 0, 0, 0)' | hoverBackgroundOverlayMode | string | Yes | Yes | 'source-over' | hoverBevelWidth | number | Yes | Yes | 0 | hoverBevelHighlightColor | Color | Yes | Yes | 'rgba(0, 0, 0, 0)' | hoverBevelShadowColor | Color | Yes | Yes | 'rgba(0, 0, 0, 0)' | hoverInnerGlowWidth | number | Yes | Yes | 0 | hoverInnerGlowColor | Color | Yes | Yes | 'rgba(0, 0, 0, 0)' | hoverOuterGlowWidth | number | Yes | Yes | 0 | hoverOuterGlowColor | Color | Yes | Yes | 'rgba(0, 0, 0, 0)' | hoverShadowOffsetX | number | Yes | Yes | 0 | hoverShadowOffsetY | number | Yes | Yes | 0 | hoverShadowBlur | number | Yes | Yes | 0 | hoverShadowColor | Color | Yes | Yes | 'rgba(0, 0, 0, 0)' | innerGlowWidth | number | Yes | Yes | 0 | innerGlowColor | Color | Yes | Yes | 'rgba(0, 0, 0, 0)' | outerGlowWidth | number | Yes | Yes | 0 | outerGlowColor | Color | Yes | Yes | 'rgba(0, 0, 0, 0)' | pointBackgroundOverlayColor | Color | Yes | Yes | 'rgba(0, 0, 0, 0)' | pointBackgroundOverlayMode | string | Yes | Yes | 'source-over' | pointBevelWidth | number | Yes | Yes | 0 | pointBevelHighlightColor | Color | Yes | Yes | 'rgba(0, 0, 0, 0)' | pointBevelShadowColor | Color | Yes | Yes | 'rgba(0, 0, 0, 0)' | pointHoverBackgroundOverlayColor | Color | Yes | Yes | 'rgba(0, 0, 0, 0)' | pointHoverBackgroundOverlayMode | string | Yes | Yes | 'source-over' | pointHoverBevelWidth | number | Yes | Yes | 0 | pointHoverBevelHighlightColor | Color | Yes | Yes | 'rgba(0, 0, 0, 0)' | pointHoverBevelShadowColor | Color | Yes | Yes | 'rgba(0, 0, 0, 0)' | pointHoverInnerGlowWidth | number | Yes | Yes | 0 | pointHoverInnerGlowColor | Color | Yes | Yes | 'rgba(0, 0, 0, 0)' | pointHoverOuterGlowWidth | number | Yes | Yes | 0 | pointHoverOuterGlowColor | Color | Yes | Yes | 'rgba(0, 0, 0, 0)' | pointHoverShadowOffsetX | number | Yes | Yes | 0 | pointHoverShadowOffsetY | number | Yes | Yes | 0 | pointHoverShadowBlur | number | Yes | Yes | 0 | pointHoverShadowColor | Color | Yes | Yes | 'rgba(0, 0, 0, 0)' | pointInnerGlowWidth | number | Yes | Yes | 0 | pointInnerGlowColor | Color | Yes | Yes | 'rgba(0, 0, 0, 0)' | pointOuterGlowWidth | number | Yes | Yes | 0 | pointOuterGlowColor | Color | Yes | Yes | 'rgba(0, 0, 0, 0)' | pointShadowOffsetX | number | Yes | Yes | 0 | pointShadowOffsetY | number | Yes | Yes | 0 | pointShadowBlur | number | Yes | Yes | 0 | pointShadowColor | Color | Yes | Yes | 'rgba(0, 0, 0, 0)' | shadowOffsetX | number | Yes | Yes | 0 | shadowOffsetY | number | Yes | Yes | 0 | shadowBlur | number | Yes | Yes | 0 | shadowColor | Color | Yes | Yes | 'rgba(0, 0, 0, 0)'

Shadow effect

The shadow effect can be controlled with the following properties.

| Name | Description | ---- | ---- | shadowOffsetX | Indicates the horizontal distance the shadow should extend from the line. See MDN. | shadowOffsetY | Indicates the vertical distance the shadow should extend from the line. See MDN. | shadowBlur | Indicates the size of the blurring effect for the line; this value doesn't correspond to a number of pixels. See MDN. | shadowColor | A standard CSS color value indicating the color of the shadow effect for the line. See Colors. | hoverShadowOffsetX | The horizontal distance the shadow should extend from the element when hovered. | hoverShadowOffsetY | The vertical distance the shadow should extend from the element when hovered. | hoverShadowBlur | The size of the blurring effect when hovered. | hoverShadowColor | The color of the shadow effect when hovered. | pointShadowOffsetX | The horizontal distance the shadow should extend from the point. | pointShadowOffsetY | The vertical distance the shadow should extend from the point. | pointShadowBlur | The size of the blurring effect for the point. | pointShadowColor | The color of the shadow effect for the point. | pointHoverShadowOffsetX | The horizontal distance the shadow should extend from the point when hovered. | pointHoverShadowOffsetY | The vertical distance the shadow should extend from the point when hovered. | pointHoverShadowBlur | The size of the blurring effect for the point when hovered. | pointHoverShadowColor | The color of the shadow effect for the point when hovered.

If the value is undefined, point* values fallback first to the dataset options then to the associated elements.point.* options. The rest of the values fallback to the associated elements.{element type}.* options.

Bevel effect

The bevel effect can be controlled with the following properties.

| Name | Description | ---- | ---- | bevelWidth | The width of the bevel effect. | bevelHighlightColor | The highlight color of the bevel effect. | bevelShadowColor | The shadow color of the bevel effect. | hoverBevelWidth | The width of the bevel effect when hovered. | hoverBevelHighlightColor | The highlight color of the bevel effect when hovered. | hoverBevelShadowColor | The shadow color of the bevel effect when hovered. | pointBevelWidth | The width of the bevel effect for the point. | pointBevelHighlightColor | The highlight color of the bevel effect for the point. | pointBevelShadowColor | The shadow color of the bevel effect for the point. | pointHoverBevelWidth | The width of the bevel effect for the point when hovered. | pointHoverBevelHighlightColor | The highlight color of the bevel effect for the point when hovered. | pointHoverBevelShadowColor | The shadow color of the bevel effect for the point when hovered.

If the value is undefined, point* values fallback first to the dataset options then to the associated elements.point.* options. The rest of the values fallback to the associated elements.{element type}.* options.

Glow effects

The glow effect can be controlled with the following properties.

| Name | Description | ---- | ---- | innerGlowWidth | The width of the inner glow effect. | innerGlowColor | The color of the inner glow effect. | outerGlowWidth | The width of the outer glow effect. | outerGlowColor | The color of the outer glow effect. | hoverInnerGlowWidth | The width of the inner glow effect when hovered. | hoverInnerGlowColor | The color of the inner glow effect when hovered. | hoverOuterGlowWidth | The width of the outer glow effect when hovered. | hoverOuterGlowColor | The color of the outer glow effect when hovered. | pointInnerGlowWidth | The width of the inner glow effect for the point. | pointInnerGlowColor | The color of the inner glow effect for the point. | pointOuterGlowWidth | The width of the outer glow effect for the point. | pointOuterGlowColor | The color of the outer glow effect for the point. | pointHoverInnerGlowWidth | The width of the inner glow effect for the point when hovered. | pointHoverInnerGlowColor | The color of the inner glow effect for the point when hovered. | pointHoverOuterGlowWidth | The width of the outer glow effect for the point when hovered. | pointHoverOuterGlowColor | The color of the outer glow effect for the point when hovered.

If the value is undefined, point* values fallback first to the dataset options then to the associated elements.point.* options. The rest of the values fallback to the associated elements.{element type}.* options.

Overlay effect

The overlay effect can be controlled with the following properties. Note that these properties are not used in a tooltip.

| Name | Description | ---- | ---- | backgroundOverlayColor | The background color overlaid on the element, which can be a standard CSS color value, a CanvasPattern or CanvasGradient object. See Colors. | backgroundOverlayMode | Indicates the type of compositing operation to apply when overlaying a color. See MDN. | hoverBackgroundOverlayColor | hoverBackgroundOverlayMode | Indicates the type of compositing operation to apply when overlaying a color when hovered. | pointBackgroundOverlayColor | The background color overlaid on the point. | pointBackgroundOverlayMode | Indicates the type of compositing operation to apply when overlaying a color on the point. | pointHoverBackgroundOverlayColor | The background color overlaid on the point when hovered. | pointHoverBackgroundOverlayMode | Indicates the type of compositing operation to apply when overlaying a color on the point when hovered.

If the value is undefined, point* values fallback first to the dataset options then to the associated elements.point.* options. The rest of the values fallback to the associated elements.{element type}.* options.

Example usage

{
    type: 'line',
    data: {
        labels: ['January', 'February', 'March', 'April', 'May', 'June'],
        datasets: [{
            data: [45, 20, 64, 32, 76, 51],
            shadowOffsetX: 3,
            shadowOffsetY: 3,
            shadowBlur: 10,
            shadowColor: 'rgba(0, 0, 0, 0.5)',
            pointBevelWidth: 3,
            pointBevelHighlightColor: 'rgba(255, 255, 255, 0.75)',
            pointBevelShadowColor: 'rgba(0, 0, 0, 0.5)',
            pointShadowOffsetX: 3,
            pointShadowOffsetY: 3,
            pointShadowBlur: 10,
            pointShadowColor: 'rgba(0, 0, 0, 0.5)',
            pointHoverInnerGlowWidth: 20,
            pointHoverInnerGlowColor: 'rgba(255, 255, 0, 0.5)',
            pointHoverOuterGlowWidth: 20,
            pointHoverOuterGlowColor: 'rgba(255, 255, 0, 1)',
            backgroundOverlayColor: ctx.createPattern(img, 'repeat'),
            backgroundOverlayMode: 'multiply'
        }]
    },
    options: {
        tooltips: {
            bevelWidth: 3,
            bevelHighlightColor: 'rgba(255, 255, 255, 0.75)',
            bevelShadowColor: 'rgba(0, 0, 0, 0.5)'
            shadowOffsetX: 3,
            shadowOffsetY: 3,
            shadowBlur: 10,
            shadowColor: 'rgba(0, 0, 0, 0.5)'
        }
    }
}

Building

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

npm install

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

gulp build            # build dist files
gulp build --watch    # build and watch for changes
gulp lint             # perform code linting
gulp package          # create an archive with dist files and samples

License

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