Javascript examples for Chart.js:Bar Chart
Chart js data-point between bar charts
<html> <head> <title>chart.js plugin-datalabels</title> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.18.1/moment.min.js"></script> <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.7.1/Chart.min.js"></script> <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/chartjs-plugin-datalabels@0.2.0/dist/chartjs-plugin-datalabels.min.js"></script> <script type="text/javascript"> window.onload=function(){/*from w ww.j a va 2 s . c o m*/ var chartData = { labels: ['2018-02-05', '2018-02-06', '2018-02-07', '2018-02-08', '2018-02-09', '2018-02-10'], datasets: [{ label: 'serie', backgroundColor: 'rgba(0, 119, 290, 0.2)', borderColor: 'rgba(0, 119, 290, 0.6)', data: [60, 80, 81, 5, 55, 40] }] }; var ctx = document.getElementById("myChart2").getContext("2d"); var myBar = new Chart(ctx, { type: 'bar', data: chartData, options: { legend: { display: false }, scales: { xAxes: [{ type: 'time', distribution: 'linear', ticks: { source: 'labels' }, time: { unit: 'day', minUnit: 'day', stepSize: 1, } }] }, plugins: { datalabels: { color: 'red', align: 'top', anchor: 'end', formatter: function(value, context) { console.log(context) if (value>70) return "("+context.dataIndex + '): ' + value; else return ""; } } } } }); } </script> </head> <body> <canvas id="myChart2" height="300" width="500"></canvas> </body> </html>