datavisyn / chartjs-plugin-error-bars Goto Github PK
View Code? Open in Web Editor NEWError Bars Chart.js Plugin
License: BSD 3-Clause "New" or "Revised" License
Error Bars Chart.js Plugin
License: BSD 3-Clause "New" or "Revised" License
Thanks for developing this plugin, exactly what we needed! Is there a way to make this plugin work with scatterplot chart?
Possibly related to #10
I'm using the plugin with chartjs 2.4.0 and it doesn't work. There's an error on line 196 of Plugin.Errorbar.js.
var errorBarColors = Array.isArray(options.color) ? options.color : [options.color];
var ctx = chart.ctx;
ctx.save(); // map error bar to barchart bar via label property
ctx is accessible at the second level, that is chart.chart (basically the chart object has another chart field, and the the context)
The code should be
var errorBarColors = Array.isArray(options.color) ? options.color : [options.color];
var ctx = chart.chart.ctx;
ctx.save(); // map error bar to barchart bar via label property
Edit: I used the master branch and built the lib using npm install & npm run build
see comment
The current version of the master branch has a bug when accessing the dataset line 191 of plugin.js
. This leads to errors on the console and does not show any error bars.
Please replace chart.data.dataset[i]
by chart.data.datasets[i]
to fix it. Or remove the whole if-clause from line 191 to line 196 (as done in develop branch).
so
x = 10
minus: -3
plus: +2
can also become
x = 10
minus: 7
plus: 12
Hey Guys!
thanks for the library! it's amazing.
I noticed that when you click on the legend name to hide the chart, the bars still appear in the canvas. how to hide them?
here in your example, try to click on one of the legends to know what i mean. https://codepen.io/sluger/pen/YjJKYy
Thanks in advance!
https://codepen.io/sgratzl/pen/PBLeJK?editors=0010
I don't understand how the error bars are scaled or defined. I define the value to be 50
and plus: 20
and minus: -30
the result looks like that:
I would expect that the upper bar is at 70 and the lower at 20 assuming these are relative values to the base value. I cannot be percentage values either since it doesn't work out with value=100
+ 20% = 120 either.
Hi,
When creating a graph with the options :
scales: { x: { type: 'time', distribution: 'series', time: { unit: 'day' } } }
Any datasets with type lineWithErrorBars
or barWithErrorBars
(didn't test others), won't be displayed.
Same thing when you update datasets after the graph is created.
Of course if you create a graph with no time series for x, the line and bar with error dataset show normally.
After graph is created with no time series, if you update x axis to become time series and if the error bar dataset is already displayed, it will stay and work normally.
Are there any display options or scriptable ways to enable and disable error bars for values that are 0? Drawing the error bar when there is not a confidence interval or when the value is zero makes for a distracting chart.
The code owner of this repository has changed, therefore it is necessary to update the repo.
This behavior is even visible in the test codepen: https://codepen.io/sluger/pen/YjJKYy
See the attached image
It would be nice if the values of the error-bars were visible in the chart's tooltips.
When adding e.g. two new datasets and remove the first two, then no error bars are left
ChartJS allows multi-lined labels of type string[][], but you can't have an array as a key. How to add error deviations to a data with multi-lined label as string[] array label?
data: {
labels: [['January', 'January line 2'], ['February', 'February line 2'], ['March', 'March line 2']],
datasets: [{
...
errorBars: {
'February': {plus: 15, minus: -34}, // the label is not 'February' but ['February', 'February line 2'] ???
'March': {plus: 5, minus: -24}
},
...
How to add the {plus, minus}
error object to the labels[0]
which is of type string[]
- [string, string]
while you can't have a string[]
key?
The demo link on code-pen no longer works.
When trying to add a second axis on the right side of the canvas, the error bars disappear
It would be nice to have an option, which enables/disables the Error Bars via Javascript
Hi,
Would you consider index-based errorBars data, rather than currently only supporting key based (even if you have tree models)?
I have a line chart, with a linear scale, where the labels are generated by using the Date() of the data row. This makes it impossible to use keys for the errorBars data.
I managed to get the plugin working as I needed by changing "dataset.forEach((bar) => {
" to "dataset.forEach((bar, ii) => {
" on line 191, and then adding this after line 204:
} else if (!hasLabelProperty && cur[ii]) { errorBarData = cur[ii];
Thanks
https://www.chartjs.org/docs/master/axes/cartesian/time
Where instead of using labels: [, ,,,]
uses data: [{x:'', y''},{x:'', y''},{x:'', y''},{x:'', y''}]
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.