chartjs-plugin-error-bars icon indicating copy to clipboard operation
chartjs-plugin-error-bars copied to clipboard

Add support for two y Axes

Open luksal opened this issue 7 years ago • 4 comments

When trying to add a second axis on the right side of the canvas, the error bars disappear

luksal avatar Jul 01 '19 22:07 luksal

Hi @luksal, can you be a bit more specific, e.g. prepare a codepen based on https://codepen.io/sluger/pen/YjJKYy

sluger avatar Jul 02 '19 06:07 sluger

Here you go: https://codepen.io/anon/pen/LKmZYo

luksal avatar Jul 02 '19 12:07 luksal

can you try https://github.com/sgratzl/chartjs-chart-error-bars since it is based on the regular chart types you should have no problem with a second axis

sgratzl avatar Sep 19 '19 22:09 sgratzl

This looks like the problem I've just been bitten by for a while.

The scale/axis ID to look at is hardcoded:

var vScale = horizontal ? chart.scales['x-axis-0'] : chart.scales['y-axis-0'];

... so if you rename it (as you have, and as I did) then it will explode - I was getting Uncaught TypeError: vScale is undefined

If you either don't give it an ID so it gets the default, or explicitly give it the ID y-axis-0, then it works, at least for me.

It would be nice if the plugin checked for the presence of the axis ID and logged a helpful message if it didn't... or even better supported multiple axes and determined which to use based on the dataset. As it stands, I think if you try to apply error bars to a second dataset which has a different axis, if it works at all the values will be plotted incorrectly, because they'd reference y-axis-0, not the axis appropriate for that dataset.

bigpresh avatar Jan 21 '21 15:01 bigpresh