1.Chart.js V2.2.2用起来实在太爽啦!
不需要自己写图例了。默认就是添加的。
http://www.chartjs.org/docs/#chart-configuration-legend-configuration
官方的教程写的非常详细。
下面我就写一个小例子:
function drawDoughnut(){
var data = {
labels: [
"Red",
"Blue",
"Yellow"
],
datasets: [
{
data: [300, 50, 100],
backgroundColor: [
"#FF6384",
"#36A2EB",
"#FFCE56"
],
hoverBackgroundColor: [
"#FF6384",
"#36A2EB",
"#FFCE56"
]
}]
};
var parameters={
type:"pie",
data:data
};
var doughnut=new Chart(ctx,parameters);
}
drawDoughnut();