chart.js - Y 축의 최대 값과 최소값 설정 포함 예제
<script src="//cdnjs.cloudflare.com/ajax/libs/Chart.js/2.4.0/Chart.min.js"></script>
<script type="text/javascript">
<!--
var ctx = document.getElementById('myChart').getContext('2d');
var chart = new Chart(ctx, {
// The type of chart we want to create
type: 'bar',
// The data for our dataset
data: {
labels: [<?
foreach($graph as $gp){
echo '"'.$gp[0].'",';
}
?>],
datasets: [{
label: "합계",
backgroundColor: 'rgba(150,200,250,0.5)',
borderColor: 'rgba(150,200,250,0.5)',
data: [<?
foreach($graph as $gp){
echo '"'.$gp[1].'",';
}
?>],
}]
},
// Configuration options go here
options: {
scales: {
yAxes: [{
display: true,
ticks: {
suggestedMax: 100, // minimum will be 0, unless there is a lower value.
// OR //
beginAtZero: true // minimum value will be 0.
}
}]
}
}
});
//-->
</script>