1

I'm trying to use the chart.js zoom plugin with my Qlik Sense extensions. Qlik is not really relevent here I guess but I will mention it anyways.

So here is how I try to load the plugin via require.js:

require.config({
    paths: {
        chart: "//cdnjs.cloudflare.com/ajax/libs/Chart.js/2.7.2/Chart.min",
        datalabels: "//cdn.jsdelivr.net/npm/chartjs-plugin-datalabels@0.3.0/dist/chartjs-plugin-datalabels.min",
        zoom: "//cdnjs.cloudflare.com/ajax/libs/chartjs-plugin-zoom/0.6.3/chartjs-plugin-zoom.min"
    },
    map: {
        datalabels: {
            "chart.js": "chart"
        },
        zoom: {
            "chart.js": "chart"
        }
    }
});

I had a similar issue with the datalabels plugin, but it was solved by the mapping in the above code snippet.

The error I always keep getting is

Uncaught TypeError: Cannot read property 'helpers' of undefined

This is coming from line 11 here .

Any help on how should I require this plugin to overcome this error? I have tried to search for a solution with no luck so far. Thanks in advance.

FranzHuber23
  • 3,311
  • 5
  • 24
  • 63
tjugg
  • 2,977
  • 2
  • 18
  • 24

1 Answers1

1

We also had a similar issue. We had tried endlessly to attempt the owners solutions however to no avail. Please see this issue and let me know about your findings: https://github.com/chartjs/chartjs-plugin-zoom/issues/73.

The issue occurs since RequireJS expects libraries to omit .js and therefore the Module ID chart.js will not load appropriately.

Regarding the error on line 11, we also replicated that issue and our conclusion was that chart was not loaded correctly.

Koshux
  • 346
  • 1
  • 2
  • 10
  • Did you happen to find any workaround for this? In the github issue you mentioned that renaming chart.js to chartjs fixed it, is this the case? – tjugg May 04 '18 at 10:35
  • That "fix" is what allowed us to load the library. It then failed on the exact error you linked here (line 11: `Uncaught TypeError: Cannot read property 'helpers' of undefined`). Unfortunately I have put this plugin usage aside due to the amount of time devoted to get it to work to no avail. With that said, I would be more than glad to help find out what is going on. – Koshux May 04 '18 at 10:38
  • Yeah, I personally just don't too good knowledge about requireJS so I am pretty limited to get help from the owners or here :-/. – tjugg May 04 '18 at 10:41