Closed MaffooClock closed 2 years ago
Hey @MaffooClock, thanks for reporting! It looks like Chartkick.js isn't expecting yAxis
to be an array. Multiple y-axes aren't officially supported, but we could probably update Chartkick.js to handle this situation without throwing an error if you'd like to submit a PR there.
Pushed a fix to Chartkick.js: https://github.com/ankane/chartkick.js/commit/63e4cf31584b651f403627391055c55f4662ebc4
I've started a new Rails 7.0 project using Webpack.
The installation instructions don't exactly match up with my environment, but I believe I have the correct setup (for Highcharts):
I can create a simple line chart with one or more series of data:
...and it renders to the view just fine.
When I attempt to implement three Y axes, with one having its own Y axis on the left, and the other two sharing the Y axis on the right (
yAxis
is being set in the dataset):...I am met with
Error Loading Chart: Cannot read properties of undefined (reading 'formatter')
. The error points toif (chartType !== "pie" && !options.yAxis.labels.formatter)
in Line 1104 -- I guessoptions.yAxis.labels
is undefined?I even tried to set the property manually:
... but no change.
When I remove the entire
library: {...}
piece, then I get Highcharts Error #18, which makes sense because the second and third datasets are specifyingyAxis: 1
, so I know the library can "see" what I'm trying to do. When I removeyAxis
from the datasets, the chart renders fine (except that all three datasets are now sharing one Y axis).HTML generated by Chartkick
Just for grits 'n' shins, I decided to comment out the entire chunk that's been giving me trouble: https://github.com/ankane/chartkick/blob/7f86b4040cbd66115ef71d072b9fefe61bf2bfaf/vendor/assets/javascripts/chartkick.js#L1104-L1108 ...and my chart rendered just exactly the way I wanted. Not certain whether there's a bug or f it's still user-error.