This is an optional decorator for KotoJS charts that allows chart authors to specify a validation schema (using JSON-SCHEMA). Attempting to set a property that is not valid will throw an Error.
// JSON SCHEMA
const schema = {
height: {
type: 'number',
minimum: 500,
default: 500
},
fill: {
type: 'color',
default: '#fff'
}
};
@KotoConfig(schema)
class Chart extends Koto {
preDraw() {
console.log('predraw');
}
}
const chart = new Chart(d3.select(document.body));
chart.config('height', 400); // => throws Error with message
chart.config('fill', 'steelblue'); // valid- boolean
- number
- minimum
- maximum
- integer
- minimum
- maximum
- string
- in
- array
- items
- color
- scale
- Object
- properties
- required
- number
- multipleOf
- array
- minLength
- maxLength
- string
- pattern
- minLength
- maxLength
$ npm startto run webpack-dev-server$ npm testto run unit tests$ npm tddto continuously run tests$ npm run jshintto lint code$ npm run buildto build (and minify)$ npm version (patch|minor|major)to create git release