Skip to content

Instantly share code, notes, and snippets.

@marorika
Created March 29, 2018 15:29
Show Gist options
  • Save marorika/6f98131c5a4cbc484d34ed06f7c4e31d to your computer and use it in GitHub Desktop.
Save marorika/6f98131c5a4cbc484d34ed06f7c4e31d 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="myLine" style="width: 100%; height: 300px;"></canvas>
<script>
var ctx = document.getElementById("myLine");
var myLine = new Chart(ctx, {
type: 'line', // チャートのタイプ
data: { // チャートの内容
labels: ["one", "two", "three", "four", "five", "six"],
datasets: [{
label: 'red',
lineTension: 0, // ベジェ曲線を無効化
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