🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

chartist-plugin-legend

Package Overview
Dependencies
Maintainers
2
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

chartist-plugin-legend

Legend plugin for Chartist.js.

0.6.2
latest
Source
npm
Version published
Weekly downloads
4.3K
-19.68%
Maintainers
2
Weekly downloads
 
Created
Source

chartist-plugin-legend

Build Status Coverage Status

Implements a legend for Chartist charts.

Demo

Install

$ npm install chartist-plugin-legend --save

As styles are very different with each project, no CSS is included. You can copy paste this to use as base:

.ct-legend {
    position: relative;
    z-index: 10;

    li {
        position: relative;
        padding-left: 23px;
        margin-bottom: 3px;
    }

    li:before {
        width: 12px;
        height: 12px;
        position: absolute;
        left: 0;
        content: '';
        border: 3px solid transparent;
        border-radius: 2px;
    }

    li.inactive:before {
        background: transparent;
    }

    &.ct-legend-inside {
        position: absolute;
        top: 0;
        right: 0;
    }

    @for $i from 0 to length($ct-series-colors) {
        .ct-series-#{$i}:before {
            background-color: nth($ct-series-colors, $i + 1);
            border-color: nth($ct-series-colors, $i + 1);
        }
    }
}

Usage

In an example chart:

require('chartist-plugin-legend');

new Chartist.Bar('.ct-chart', data, {
        stackBars: true,
        plugins: [
            Chartist.plugins.legend()
        ]
    },
});
OptionDescriptionTypeDefault
classNameAdds a class to the ul element.string''
clickableSets the legends clickable state; setting this value to false disables toggling graphs on legend click.booltrue
legendNamesSets custom legend names. By default the name property of the series will be used if none are given.mixedfalse
onClickAccepts a function that gets invoked if clickable is true. The function has the chart, and the click event (e), as arguments.mixedfalse
classNamesAccepts a array of strings as long as the chart's series, those will be added as classes to the li elements.mixedfalse
removeAllAllow all series to be removed at once.boolfalse
positionSets the position of the legend element. top, bottom or any DOM2 Element are currently accepted. If a DOM Element is given, the legend will be appended as it's last child.`'top''bottom'

FAQs

Package last updated on 05 Aug 2017

Did you know?

Socket

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