편집하다
나는 charts.js 라이브러리를 사용하고 있으며 내 y 축에서 특정 눈금을 숨길 수 있는지 알고 싶었습니다. 예를 들어 눈금의 min : 0 및 max : 100을 정의했으며 모든 값을 10의 배수로 표시했습니다. 0에서 100까지,하지만 0, 50 e 100 만 표시하고 싶습니다. (해결됨)
또 다른 문제는 모든 x 축의 격자 선을 제거하고 싶었지만 "gridLines.display : false"메서드는 차트 시작 부분의 첫 번째 세로선을 숨기지 않고 나머지는 숨 깁니다.
이것이 내가 원하는 모습입니다 : http://i.stack.imgur.com/GryIo.png
스크립트
var humdays = document.getElementById("charthumdays");
var humdaysChart = new Chart(humdays, {
type: 'bar',
data: {
labels: ["15 mar", "16 mar", "17 mar", "18 mar", "19 mar", "20 mar", "21 mar"],
datasets: [{
label: "humidity",
data: [60, 20, 30, 50, 60, 80, 90],
backgroundColor: "#D9B090",
hoverBackgroundColor: 'rgba(217,176,144,0.8)'
}]
},
options: {
scales: {
xAxes : [{
gridLines : {
display : false
}
}],
yAxes: [{
ticks: {
min:0,
max:100
}
}]
}
}
});
humdaysChart.options.legend.display = false;
스케일 / yAxes에 afterBuildTicks 옵션 사용
yAxes: [{
ticks: {
min: 0,
max: 100
},
afterBuildTicks: function(humdaysChart) {
humdaysChart.ticks = [];
humdaysChart.ticks.push(0);
humdaysChart.ticks.push(50);
humdaysChart.ticks.push(100);
}
}]
또는 'stepSize' 를 사용할 수도 있습니다.
yAxes: [{
ticks: {
min:0,
max:100,
stepSize:50
}
}]
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다