highcharts-config v1.1.0
highcharts-config
Table of contents
Installation
yarn
$ yarn add highcharts-confignpm
$ npm i highcharts-config --saveUsage
import buildConfig from 'highcharts-config';
const config = buildConfig()
// use shorthand methods to set properties on the object
.title('text', 'My fancy chart')
.colors([
'red',
'yellow',
'blue',
'green'
])
// then add types of charts
.addType('spline', {
data: [3, 5, 6, 2, 10, 7],
name: 'Average'
})
.addType('column', {
name: 'Total',
data: [
{name: 'Foo', y: 13},
{name: 'Bar', y: 23},
{name: 'Baz', y: 19}
],
})
// finally, retrieve the built config
.get();Summary
Highcharts is a fantastic charting library, but it's configuration can be daunting and confusing. highcharts-config tries to simplify this process with a natural API and a focus on reusability. There are chainable convenience methods for both chart and global options configurations, and each step in the chain returns a new instance so it can be stored and reused.
It should be noted that while the construct of immutability is applied when updating the configurations, it is not rigidly enforced (Highcharts barks when the configuration is deeply frozen). This means you can mutate the configuration directly without the use of the API, however it is highly discouraged.
API
Check out the API page for complete information.
Development
Standard stuff, clone the repo and yarn / npm install dependencies. The npm scripts available:
build=> run webpack to build developmentdistfile with NODE_ENV=developmentbuild:minifed=> run webpack to build productiondistfile with NODE_ENV=productiondev=> run webpack dev server to run example app (playground)lint=> run ESLint against all files in thesrcfolderprepublish=> runsprepublish:compileprepublish:compile=> runlint,test:coverage,transpile,build, andbuild:minifiedtest=> run AVA test functions withNODE_ENV=testtest:coverage=> runtestbut withnycfor coverage checkertest:watch=> runtest, but with persistent watchertranspile=> run babel against all files insrcto create files inlib