Chart.js ticks.callback

by Akihiko Kusanagi

HTML

<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.7.3/Chart.bundle.js"></script>
<canvas id="myChart" width=512 height=256></canvas>

JavaScript

var ctx = document.getElementById('myChart').getContext('2d');
var chart = new Chart(ctx, {
				type: 'line',
				data: {
					datasets: [{
						xAxisID: 'xScale0',
						data: [0, 0]
					}],
					labels: ['2015-01-01T20:00:00', '2015-01-01T20:01:00']
				},
				options: {
        responsive: false,
					scales: {
						xAxes: [{
							id: 'xScale0',
							type: 'time',
							ticks: {
              	fontColor: 'red',
								callback: function(value) {
									return '<' + value + '>';
								},
								major: {
                  enabled: true,
									fontColor: 'green',
								callback: function(value) {
										return '[' + value + ']';
									}
								},
								minor: {
									fontColor: 'blue',
								callback: function(value) {
										return '(' + value + ')';
									}
								}
							}
						}]
					}
				}
});