chartjs issue 4560
reproduce https://codepen.io/tomkcook/pen/LjELzg for https://github.com/chartjs/Chart.js/issues/4560
by microMerlin
HTML
<script src="https://npmcdn.com/chart.js@latest/dist/Chart.bundle.min.js"></script>
<div class="myChartDiv">
<canvas id="myChart" width="600" height="400"></canvas>
</div>
CSS
.myChartDiv {
max-width: 600px;
max-height: 400px;
}
JavaScript
var ctx = document.getElementById("myChart");
var myChart = new Chart(ctx, {
type: 'bar',
data: {
labels: [ new Date(2017, 7, 24, 0),
new Date(2017, 7, 24, 1),
new Date(2017, 7, 24, 2),
new Date(2017, 7, 24, 3),
new Date(2017, 7, 24, 4),
new Date(2017, 7, 24, 5),
new Date(2017, 7, 24, 6),
new Date(2017, 7, 24, 7),
new Date(2017, 7, 24, 8),
new Date(2017, 7, 24, 9),
new Date(2017, 7, 24, 10),
new Date(2017, 7, 24, 11)],
datasets: [{
label: '# of Votes',
data: [100, 200, 100, 400, 300, 100, 100, 200, 100, 400, 300, 100, 100, 200, 100, 400]
}]
},
options: {
scales: {
xAxes: [{
type: 'time',
time: {
unit: 'day',
min: new Date(2017, 7, 24, 0),
max: new Date(2017, 7, 31)
},
barThickness: 2
}],
yAxes: [{
ticks: {
beginAtZero:true
}
}]
}
}
});