Chart.js #5609 test01
HTML
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.22.2/moment.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.7.2/Chart.min.js"></script>
<canvas id="myChart1"></canvas>
<canvas id="myChart2"></canvas>
<canvas id="myChart3"></canvas>
<canvas id="myChart4"></canvas>
<canvas id="myChart5"></canvas>
<canvas id="myChart6"></canvas>
<canvas id="myChart7"></canvas>
<canvas id="myChart8"></canvas>
JavaScript
var ctx1 = document.getElementById('myChart1').getContext('2d');
var chart1 = new Chart(ctx1, {
type: 'bar',
data: {
labels: ['January'],
datasets: [{
data: [1]
}]
},
options: {
title: {
display: true,
text: '1. bar chart with category scale (offset: true, offsetGridLines: true)'
},
scales: {
xAxes: [{
type: 'category',
offset: true,
gridLines: {offsetGridLines: true},
}],
yAxes: [{
ticks: {
beginAtZero: true,
}
}]
}
}
});
var ctx2 = document.getElementById('myChart2').getContext('2d');
var chart2 = new Chart(ctx2, {
type: 'bar',
data: {
labels: ['January','February'],
datasets: [{
data: [1,2]
}]
},
options: {
title: {
display: true,
text: '2. bar chart with category scale (offset: true, offsetGridLines: true)'
},
scales: {
xAxes: [{
type: 'category',
offset: true,
gridLines: {offsetGridLines: true},
}],
yAxes: [{
ticks: {
beginAtZero: true
}
}]
}
}
});
var ctx3 = document.getElementById('myChart3').getContext('2d');
var chart3 = new Chart(ctx3, {
type: 'line',
data: {
labels: ['January'],
datasets: [{
data: [1]
}]
},
options: {
title: {
display: true,
text: '3. line chart with category scale (offset: true, offsetGridLines: true)'
},
scales: {
xAxes: [{
type: 'category',
offset: true,
gridLines: {offsetGridLines: true}
}],
yAxes: [{
ticks: {
beginAtZero: true
}
}]
}
}
});
var ctx4 = document.getElementById('myChart4').getContext('2d');
var chart4 = new Chart(ctx4, {
type: 'line',
data: {
labels: ['January','February'],
datasets: [{
data: [1,2]
}]
},
options: {
title: {
display: true,
text: '4. line chart with category scale (offset: true,...