• Stars
    star
    116
  • Rank 303,894 (Top 6 %)
  • Language
    JavaScript
  • License
    Other
  • Created over 9 years ago
  • Updated over 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Legend plugin for Chartist.js.

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()
        ]
    },
});
Option Description Type Default
className Adds a class to the ul element. string ''
clickable Sets the legends clickable state; setting this value to false disables toggling graphs on legend click. bool true
legendNames Sets custom legend names. By default the name property of the series will be used if none are given. Multiple series can be associated with a legend item using this property as well. See examples for more details. mixed false
onClick Accepts a function that gets invoked if clickable is true. The function has the chart, and the click event (e), as arguments. mixed false
classNames Accepts a array of strings as long as the chart's series, those will be added as classes to the li elements. mixed false
removeAll Allow all series to be removed at once. bool false
position Sets 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'

More Repositories

1

run-headless-chromium

Run Chromium or Google Chrome in headless mode and forward the JS console output to the standard output.
JavaScript
250
star
2

mobx-spine

MobX with support for models, relations and an external API.
JavaScript
31
star
3

django-relativedelta

Django field for python-dateutil relativedelta
Python
20
star
4

django-binder

A framework based on Django for SPA webapps with a REST-like API
Python
14
star
5

vagrant-reverse-proxy

Automatic reverse VM proxy plugin for Vagrant
Ruby
8
star
6

chartist-plugin-tooltip

Tooltip plugin for Chartist.js
JavaScript
7
star
7

re-cy-cle

React component library for Code Yellow
JavaScript
6
star
8

chartist-plugin-animation

Default animations plugin for Chartist.js
JavaScript
5
star
9

high-templar

A python framework for creating a server which handles websockets for an existing API
Python
5
star
10

react-multipick

A multiselect dropdown package for React.
JavaScript
5
star
11

deviceReady

JavaScript
4
star
12

devstack-frontend

Our default setup for developing single page apps.
JavaScript
4
star
13

backbone-relation

Simple support for relations for Backbone models
JavaScript
4
star
14

chartist-plugin-axis-label

Axis labels plugin for Chartist.js
JavaScript
3
star
15

django-postgres-setfield

Django field plugin for sets, backed by array storage in PostgreSQL
Python
3
star
16

rails-formbuilder

Form builder plugin for Ruby On Rails
Ruby
2
star
17

realtime

Time tracking application for Code Yellow-ers
JavaScript
2
star
18

marionette-busy

A Marionette Behavior for showing a busy message / loader.
JavaScript
2
star
19

backbone-crux

A set of opinionated additions to Backbone
JavaScript
1
star
20

marionette-notifications

Show notifications in a Marionette region
JavaScript
1
star
21

jquery-csrf-token

Adds a CSRF header to each AJAX request
JavaScript
1
star
22

daycy

Simple date (range) picker for React based on Semantic-UI.
JavaScript
1
star
23

marionette-throttle

Marionette behavior for throttling methods.
JavaScript
1
star
24

cordova-plugin-wifi-access

Enable WiFi access on Android in your Cordova project (makes it easier to integrate Crosswalk into your project)
1
star