<script>
var ctx = document.getElementById('myChart').getContext('2d');
var myChart = new Chart(ctx, {
type: 'line',
data: {
labels: ["2010","2011","2012","2013","2014","2015"],
datasets: [
{
label: "JAPAN",
fill: false, // 下方の塗りつぶしせず
backgroundColor: "#3A7AC9",
borderWidth: 2,
borderColor: "rgba(2,63,138,0.8)",
pointBorderColor: "#fff",
pointBackgroundColor: "rgba(2,63,138,0.8)",
pointBorderWidth: 2,
pointHoverRadius: 5,
pointHoverBackgroundColor: "#1D5191",
pointHoverBorderColor: "#fff",
pointHoverBorderWidth: 2,
tension: 0.2,
data: [5, 7, 8, 3, 1, 4]
}, {
label: "日本",
fill: false, // 下方の塗りつぶしせず
backgroundColor: "#DB514E",
borderWidth: 2,
borderColor: "rgba(201,60,58,0.8)",
pointBorderColor: "#fff",
pointBackgroundColor: "rgba(201,60,58,0.8)",
pointBorderWidth: 2,
pointHoverRadius: 5,
pointHoverBackgroundColor: "#9A1B19",
pointHoverBorderColor: "#fff",
pointHoverBorderWidth: 2,
tension: 0.2,
data: [1, 4, 4, 2, 6, 7]
}
] // datasets ---------
},
options: {
responsive: false,
plugins: {
title: {
display: true,
text: 'Chart.js v.3 Line Chart',
font: { size: 14, },
},
legend: {
display: true,
position: 'top',
},
}, // plugins ------
scales: {
x: {
display: true,
title: {
display: true,
text: '西暦 年',
font: { size: 14 },
},
},
y: {
display: true,
title: {
display: true,
text: '順位',
font: { size: 14 },
},
reverse: true, // 逆向き目盛
ticks: {
callback: function(value){
return value+'位'; // 目盛の編集
}
}
} // y ------
} // scales -------
}, // options ------
}); // var myChart ------
</script>