【发布时间】:2016-06-04 20:26:15
【问题描述】:
如何在 chartjs 2.0 分支上使用 angular-chartjs 使条形图中的每个条具有不同的颜色?
我的画布如下所示:
<canvas class="chart chart-bar"
chart-data="GBCC.setData"
chart-labels="GBCC.labels"
chart-options="GBCC.options"
chart-colors="GBCC.colors"
height="68"
width="300">
</canvas>
我的 GBCC 控制器如下所示:
this.labels = ['hello', 'world', 'foobar'];
this.setData = [[50, 20, 95]];
this.colors = [
'#DCDCDC', // light grey
'#F7464A', // red
'#46BFBD', // green
];
this.options = {
scales: {
yAxes: [{
display: true,
ticks: {
beginAtZero: true,
min: 0,
max: 100,
stepSize: 20
}
}]
}
};
它将所有条形更改为数组中的第一种颜色,但不使用其他颜色。有人知道怎么做吗?
【问题讨论】:
标签: angularjs chart.js angular-chart