Skip to content

Instantly share code, notes, and snippets.

@marorika
Created March 29, 2018 15:38
Show Gist options
  • Save marorika/28649df6a98e818aeb49b6c2ca0881f7 to your computer and use it in GitHub Desktop.
Save marorika/28649df6a98e818aeb49b6c2ca0881f7 to your computer and use it in GitHub Desktop.
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.7.2/Chart.bundle.min.js"></script>
<canvas id="myBar" style="width: 100%; height: 300px;"></canvas>
<script>
var myBarElement = document.getElementById("myBar");
var myBar = new Chart(myBarElement, {
type: 'bar', // チャートのタイプ
data: { // チャートの内容
labels: ["one", "two", "three", "four", "five", "six"],
datasets: [{
label: 'red',
data: [12, 19, 3, 5, 2, 3],
backgroundColor: 'RGBA(182,39,93, 0.4)',
borderColor: 'RGBA(182,39,93, 1)',
borderWidth: 1
}, {
label: 'green',
data: [10, 14, 6, 8, 1, 4],
backgroundColor: 'RGBA(77,169,155, 0.4)',
borderColor: 'RGBA(77,169,155, 1)',
borderWidth: 1
}]
},
options: { // チャートのその他オプション
scales: {
yAxes: [{
ticks: {
beginAtZero:true
}
}]
}
}
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment