chartjs / Chart.js

Simple HTML5 Charts using the <canvas> tag
https://www.chartjs.org/
MIT License
64.49k stars 11.89k forks source link

Plugin funnel doesn't work in >2.7.3 #6828

Closed poradz closed 4 years ago

poradz commented 4 years ago

Expected Behavior

Plugin funnel should work as previously.

Current Behavior

Chart.js:4879 Uncaught TypeError: Cannot read property 'options' of undefined
    at ChartElement.initialize (Chart.js:4879)
    at ChartElement.initialize (chart.funnel.min.js? [sm]:1)
    at ChartElement.DatasetController (Chart.js:3617)
    at new ChartElement (Chart.js:2395)
    at Chart.buildOrUpdateControllers (Chart.js:9573)
    at Chart.update (Chart.js:9626)
    at Chart.construct (Chart.js:9357)
    at new Chart (Chart.js:9294)
    at c.loadChart (Widget.js:1920)
    at c.postLoadWidget (Widget.js:1472)

Possible Solution

DatasetController should have _getIndexScale() function.

Steps to Reproduce (for bugs)

https://gitdeveloper.yetiforce.com/index.php

Context

Environment

benmccann commented 4 years ago

DatasetController should have _getIndexScale() function.

Chart.js 2.9.3 does have a _getIndexScale() method. If you're trying to use the code in master the please be aware that we are working Chart.js 3.0, which breaks backwards compatibility, but provides numerous improvements including being massively faster. In that case you will have to use meta.iScale.

poradz commented 4 years ago

You are right, the _getIndexScale() method exists. Thank you for your suggestion, we will definitely be eager to support 3.0.

At this moment I fixed this by adding xAxes to plugin, previously yAxes was enough. I am quite new in chart.js so I am not sure if it is the right way.

https://github.com/YetiForceCompany/chartjs-plugin-funnel/commit/f7829215ff2aefa3392f0b44dbb8b08e625c2b2e#diff-970c199009b0bd250e8c75702ff0bd78L268

benmccann commented 4 years ago

Cool. Glad it's working!

You might consider submitting your plugin to https://github.com/chartjs/awesome