【发布时间】:2020-08-31 05:30:44
【问题描述】:
我试着让蜱虫变成红色。但它不起作用。当标签没有标签时 - Sa/Su 它工作。所有标签 - 灰色,但当我有 Su 或 Sa 标签时,只显示黑色
ticks: {
fontSize: 9,
fontColor: curLabels.map((item) => {
if(item === 'Su' || item === 'Sa')
return 'red';
return 'rgba(0, 0, 0, 0.4)';
}),
maxRotation: 0,
},
已编辑:
<div style={{height: '100%'}} className='position-relative'>
<Line
key='lineChart17'
data={dataForChart}
options={lineOptions}
style={{height: '90px', padding: '5px', width: '100%'}}
redraw
/>
</div>
图表选项。我得到错误 - 蜱没有属性专业。在控制台中,它只是字符串 - Mo/Th/Fr/We/Su ...:
const lineOptions = {
animation: {
duration: 0
},
layout:{
padding:{
left: 0,
right: 0,
top: 5,
bottom: 0
}
},
maintainAspectRatio: false,
scales: {
xAxes: [{
display: true,
gridLines: {
display: true,
tickMarkLength: 1,
},
ticks: {
fontSize: 9,
fontColor: 'rgba(0, 0, 0, 0.4)',
maxRotation: 0,
major: {
enabled: true,
fontStyle: 'bold',
fontColor: 'red'
},
},
afterBuildTicks: (scale, ticks) => {
ticks.forEach(t => {
t.major = (t === 'Su');
});
return ticks;
},
}],
yAxes: [{
display: false,
gridLines: {
display: false,
tickMarkLength: 1,
},
}],
},
};
【问题讨论】:
标签: javascript reactjs label chart.js option