Home >Web Front-end >HTML Tutorial >【】How to display the legend using Chart.js drawing? _html/css_WEB-ITnose

【】How to display the legend using Chart.js drawing? _html/css_WEB-ITnose

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-24 11:45:11964browse

As shown in the picture, now that Chart.js is used to draw a pie chart or bar chart, how can I display the corresponding legend next to it?


Reply to discussion (solution)

var myChart = new Chart(ctx).Pie(data, options)var legend = myChart.generateLegend();


legend is the HTML code generated by the template, which can be set It is the innerHTML of a certain element and then displayed

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn