我有一个使用chart.js版本2.4和angular-chart.js的多线图。我想分别以红色和绿色显示2行,我不想在线下填充颜色。我怎么能实现这一点?
var app=angular.module("app", ["chart.js"]);
app.controller("LineCtrl", function ($scope) {
$scope.labels = ["January", "February", "March", "April", "May", "June", "July","August","September","October","November","December"];
$scope.series = ['one', 'two'];
$scope.data = [
[65, 59, 80, 81, 56, 55, 40, 30, 70, 30, 70, 30],
[28, 48, 40, 19, 86, 27, 90, 35, 70, 62, 75, 60]
];
$scope.onClick = function (points, evt) {
console.log(points, evt);
};
$scope.datasetOverride = [{ yAxisID: 'y-axis-1' }, { yAxisID: 'y-axis-2' }];
$scope.options = {
scales: {
yAxes: [
{
id: 'y-axis-1',
type: 'linear',
display: true,
position: 'left'
},
{
id: 'y-axis-2',
type: 'linear',
display: true,
position: 'right'
}
]
}
};
});
答案 0 :(得分:1)
做这样的事,
ctrl.datasetOverride = [{
fill: false,
backgroundColor: [
"#ED402A",
"#36A2EB",
"#FFCE56"
]
}, {
fill: false,
backgroundColor: [
"#F0AB05",
"#36A2EB",
"#FFCE56"
]
}
];
<强> DEMO 强>