我一直在尝试为不同的区域启用不同的颜色,但我找不到为不同的对象设置不同颜色的方法。
我正在从数据库中获取数据,然后对其进行处理并按如下方式进行处理。
我很感激您对如何更改不同项目的颜色的看法
//looping through the data
for(var i in data) {
CarPrices.push(data[i].name);
score.push(data[i].price);
}
//Working with data fetched from database
var chartdata = {
labels: player,
datasets : [
{
//Trying to change background color for each element
label: 'Car Prices',
backgroundColor: [
"#FF6384",
"#36A2EB",
"#FFCE56"
],
//Trying to change background color for each element**
hoverBackgroundColor: [
"#FF6384",
"#36A2EB",
"#FFCE56"
],
}
]
};
Run Code Online (Sandbox Code Playgroud) 我正在使用chart.js,我想为我的数据设置自定义日期格式.我怎样才能做到这一点?
例如,这是我的x轴日期配置:
scales: {
xAxes: [{
type: 'time',
position: 'bottom',
time: {
displayFormats: {
**'day': 'Y M D',
'week': 'Y M D',
'month': 'Y M D',
'year': 'Y M D',**
}
},
Run Code Online (Sandbox Code Playgroud)
如何控制工具提示和轴刻度标签格式.