|
1 | | -# chartjs-plugin-error-bars |
2 | | -Error Bars Chart.js Plugin |
| 1 | +# Chart.js Error Bars Plugin |
| 2 | +[![datavisyn][datavisyn-image]][datavisyn-url] [![NPM Package][npm-image]][npm-url] [![CircleCI][circleci-image]][circleci-url] |
| 3 | + |
| 4 | +[Chart.js](http://www.chartjs.org/) plugin for adding error bars to Line-, Barcharts or hierarchical Barcharts. This plugin also works with the [Hierarchical Scale Plugin](https://github.com/datavisyn/chartjs-scale-hierarchical). |
| 5 | + |
| 6 | + |
| 7 | + |
| 8 | + |
| 9 | + |
| 10 | +## Install |
| 11 | +```bash |
| 12 | +npm install --save chart.js chartjs-plugin-error-bars |
| 13 | +``` |
| 14 | + |
| 15 | +## Usage |
| 16 | +Datasets must define an `errorBars` object that contains the error bar property key (same as in the used scale) and values `plus` and `minus`. Plus values are always positive, and minus vice versa. |
| 17 | + |
| 18 | +*Categorical scale usage:* |
| 19 | +```javascript |
| 20 | + data: { |
| 21 | + labels: ['January', 'February', 'March', 'April', 'May', 'June', 'July'], |
| 22 | + datasets: [{ |
| 23 | + ... |
| 24 | + errorBars: { |
| 25 | + 'February': {plus: 15, minus: -34}, |
| 26 | + 'March': {plus: 5, minus: -24}, |
| 27 | + 'May': {plus: 35, minus: -14}, |
| 28 | + 'June': {plus: 45, minus: -4} |
| 29 | + }, ... |
| 30 | +``` |
| 31 | +
|
| 32 | +*Hierarchical scale plugin usage:* |
| 33 | +```javascript |
| 34 | + data: { |
| 35 | + labels: [ |
| 36 | + 'A', |
| 37 | + { |
| 38 | + label: 'C1', |
| 39 | + children: ['C1.1', 'C1.2', 'C1.3', 'C1.4'] |
| 40 | + } |
| 41 | + ], |
| 42 | + datasets: [{ |
| 43 | + ... |
| 44 | + errorBars: { |
| 45 | + 'A': {plus: 25, minus: -10}, |
| 46 | + 'C1.2': {plus: 14, minus: -15}, |
| 47 | + 'C1': {plus: 34, minus: -5} |
| 48 | + }, ... |
| 49 | + } |
| 50 | +``` |
| 51 | +
|
| 52 | +Find more [Samples](https://github.com/datavisyn/chartjs-plugin-error-bars/tree/master/samples) on Github. |
| 53 | +
|
| 54 | +
|
| 55 | +## Options |
| 56 | +```javascript |
| 57 | + options: { |
| 58 | + ... |
| 59 | + |
| 60 | + plugins: { |
| 61 | + chartJsPluginErrorBars: { |
| 62 | + /** |
| 63 | + * stroke color |
| 64 | + * @default: derived from borderColor |
| 65 | + */ |
| 66 | + color: '#666' |
| 67 | + |
| 68 | + /** |
| 69 | + * bar width in pixel as number or string or bar width in percent based on the barchart bars width (max 100%) |
| 70 | + * @default 10 |
| 71 | + */ |
| 72 | + width: 10 | '10px' | '60%' |
| 73 | + } |
| 74 | + } |
| 75 | + |
| 76 | + ... |
| 77 | +} |
| 78 | +``` |
| 79 | +
|
| 80 | +
|
| 81 | +## Building |
| 82 | +
|
| 83 | +```sh |
| 84 | +npm install |
| 85 | +npm run build |
| 86 | +``` |
3 | 87 |
|
4 | | -> in development |
5 | 88 |
|
6 | 89 | *** |
7 | 90 |
|
8 | 91 | <div style="display:flex;align-items:center"> |
9 | 92 | <a href="http://datavisyn.io"><img src="https://user-images.githubusercontent.com/1711080/37700685-bcbb18c6-2cec-11e8-9b6f-f49c9ef6c167.png" align="left" width="50px" hspace="10" vspace="6"></a> |
10 | | - Developed by <strong><a href="http://datavisyn.io">datavisyn</a></strong>. |
| 93 | + Developed by <strong><a href="http://datavisyn.io">datavisyn</a></strong>. |
11 | 94 | </div> |
| 95 | +
|
| 96 | +[datavisyn-image]: https://img.shields.io/badge/datavisyn-io-black.svg |
| 97 | +[datavisyn-url]: http://datavisyn.io |
| 98 | +[npm-image]: https://badge.fury.io/js/chartjs-plugin-error-bars.svg |
| 99 | +[npm-url]: https://npmjs.org/package/chartjs-plugin-error-bars |
| 100 | +[circleci-image]: https://circleci.com/gh/datavisyn/chartjs-plugin-error-bars.svg?style=shield |
| 101 | +[circleci-url]: https://circleci.com/gh/datavisyn/chartjs-plugin-error-bars |
0 commit comments