0
グリッド線がfalseに表示された棒グラフがあります。今、軸線(xとy)に対してのみ、幅と色を設定する必要があります。私はグリッド線を非表示にするとき、私は唯一の軸の、スタイリング(幅や色)を設定することができません、しかしグリッド線が隠されているときのChartJS棒グラフの軸のスタイルの編集
options:{
scales: {
xAxes: [{
gridLines: {
color: "rgba(0,0,0,1)",
lineWidth: 1
}
}],
yAxes: [{
gridLines: {
color: "rgba(0,0,0,1)",
lineWidth: 1
}
}],
}
}
:私はこれらの値を設定することができます。
options:{
scales: {
xAxes: [{
gridLines: {
display:false
}
}],
yAxes: [{
gridLines: {
display:false
}
}],
}
}
私はscaleLineColorを試しましたが、それも機能していないようです。ここに私の完全なコードは次のとおりです。
var q1 = document.getElementById("q1").getContext('2d');
var q1Chart = new Chart(q1, {
type: 'bar',
data: {
labels: ["Very Good(9-10)","Good(8-7)","OK(5-6)","Bad (3-4)","Cant be worse (0-2)"],
datasets: [{
label: "Our Performance",
data: [19.56,37.90,1.29,30.36,10.89],
backgroundColor: ["#d93030","#288fba","#367fa9","#367fa9","#367fa9"],
datalabels: {
align: 'top',
anchor: 'end',
font: {
size: 18,
weight: 900,
},
formatter: function(value) {
var label = value;
var keys, klen, k;
return label + '%';
}
}
}]
},
scaleLineColor: "rgba(0,0,0,1)",
options:{
scales: {
xAxes: [{
barThickness : 50,
ticks: {
fontColor: "black",
fontSize: 20,
autoSkip: false,
},
gridLines: {
display:false
}
}],
yAxes: [{
ticks: {
fontColor: "black",
fontSize: 20,
beginAtZero: true,
stepSize: 10
},
gridLines: {
display:false
}
}],
},
responsive: false,
maintainAspectRatio: true,
legend: {
display: false
},
tooltips: {
enabled: false
},
layout: {
padding: {
left: 0,
right: 0,
top: 30,
bottom: 0
}
}
},
});
おかげで多くのことを行うためのプラグインを作成することです。魅力的な作品! – gentrobot