Chart.js - generateLegend () the result of a call to "undefined is not a function"

When I try to call generateLegened () on my chart:

var ctx = $("#chart").get(0).getContext("2d"); var ctxOptions = { responsive: false, legendTemplate: "<ul>LEGEND</ul>" }; var chart = new Chart(ctx); chart.Line(data, ctxOptions); var legend = chart.generateLegend(); 

these are errors with:

Uncaught TypeError: undefined is not a function

in the line chart.GenerateLegend ().

I am completely confused that this is a problem. The function is explicitly located in the included .js file.

I am using this script: //cdnjs.cloudflare.com/ajax/libs/Chart.js/1.0.1/Chart.min.js

Is this a mistake, or can someone tell me what I'm doing wrong?

thanks

+5
source share
2 answers

I wonder if I change the code as follows:

 var chart = new Chart(ctx).Line(data, ctxOptions); 

The legend works as expected !?

Error with chart.js?

+4
source

Try

 legendTemplate: function(data) { return "<ul>LEGEND</ul>"; } 

instead of this. There seems to be some errors in chart.js.

+1
source

Source: https://habr.com/ru/post/1212272/


All Articles