Skip to content

Instantly share code, notes, and snippets.

@marorika
Last active March 29, 2018 15:46
Show Gist options
  • Save marorika/98138fd12ec69442380c0ba9c72a1db4 to your computer and use it in GitHub Desktop.
Save marorika/98138fd12ec69442380c0ba9c72a1db4 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="myScatter" style="width: 100%; height: 300px;"></canvas>
<script>
var myScatterElement = document.getElementById("myScatter");
var myScatter = new Chart(myScatterElement, {
type: 'scatter', // チャートのタイプ
data: { // チャートの内容
datasets: [{
label: 'red',
data: [{x:4, y:5}, {x:5, y:9}],
backgroundColor: 'RGBA(182,39,93, 0.4)',
borderColor: 'RGBA(182,39,93, 1)',
borderWidth: 1
}, {
label: 'green',
data: [{x:8, y:4}, {x:2, y:4}],
backgroundColor: 'RGBA(77,169,155, 0.4)',
borderColor: 'RGBA(77,169,155, 1)',
borderWidth: 1
}]
},
options: { // チャートのその他オプション
scales: {
xAxes: [{
ticks: {
max: 10,
min: 0
}
}],
yAxes: [{
ticks: {
max: 10,
min: 0
}
}]
}
}
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment