Chart.js icon indicating copy to clipboard operation
Chart.js copied to clipboard

generateLegend() only works for global variables

Open joakimdahlstrom opened this issue 12 years ago • 3 comments

When using chart.generateLegend(), the variables referenced in options.legendTemplate must exist globally.

Using chart.generateLegend() within a function will result in "data is not defined" where data is the variable with the chart data.

If I do window.data = data; before, it works.

joakimdahlstrom avatar Aug 05 '14 14:08 joakimdahlstrom

Hello, this issue looks like a QUESTION regarding the Chart.js API. It would be very helpful if you could please create an example chart showing your attempt, and even call the methods that don't exist yet which you are expecting to be there. A mockup here of what the result should look like would be for bonus points.

To help, I have created a simple JSBIN which you could fork: http://jsbin.com/yozobahucero/1/edit?html,js,output

Sorry that this response is templated as we are triaging many issues and ones with test cases will be seen first.

fulldecent avatar Sep 25 '14 18:09 fulldecent

This seems to be fixed in the latest version. But if you are still seeing this problem, please add a test case and reopen.

fulldecent avatar Jan 19 '15 00:01 fulldecent

Hi fulldecent,

It seems the issue still occur. Here is my jsfiddle https://fiddle.jshell.net/jomarv/fehxxuns/9/, Im using version 2.5.0

jgverzosa avatar Jun 16 '17 01:06 jgverzosa