【发布时间】:2020-04-09 19:30:10
【问题描述】:
我正在使用 node-canvas 模块导出圆环图。
这是我的代码:
const barChartOptions = {
responsive: true,
aspectRatio: 1,
cutoutPercentage: 75,
maintainAspectRatio: true,
legend: {
position: 'bottom',
labels: {
boxWidth: 10,
fontSize: 11,
color: '#959ead'
}
}
};
const barChartLabels = ['Vantaggi, Svantaggi'];
const barChartType = 'doughnut';
export const getBarConfiguration = (data: any[]) => ({
type: barChartType,
data: {
labels: barChartLabels,
datasets: [{
data: [50, 20],
backgroundColor: ['#69c499', '#fb5b5b']
}]
},
options: barChartOptions
});
这就是我得到的chart
正如您在图例中看到的那样,我只能看到一种颜色,但我希望同时看到两种颜色(图表中的红色和绿色),此外,我还想显示工具提示。
谢谢
【问题讨论】: