Javascript examples for Chart.js:Chart Data
Chart.js place y value position and x-label position relative to the x-value
<html> <head> <title>x and y coordinates in chart data</title> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript" src="https://npmcdn.com/chart.js@latest/dist/Chart.bundle.min.js"></script> <script type="text/javascript"> window.onload=function(){/* www.j av a 2 s .c om*/ var graphData = [ { "x": 1, "y": 10 }, { "x": 2, "y": 12 }, { "x": 3, "y": 12 }, { "x": 9, "y": 12 }, { "x": 16, "y": 17 } ]; var ctx = document.getElementById("myChart"); var myChart = new Chart(ctx, { type: 'scatter', data: { datasets: [{ fill: false, lineTension: 0, borderColor: "blue", pointRadius: 5, pointBorderColor: "red", pointBorderWidth: 3, data: graphData }] }, options: { scales: { xAxes: [{ ticks: { beginAtZero: true, max: 18 } }], yAxes: [{ ticks: { beginAtZero: true } }] }, legend: { display: false, } } }); } </script> </head> <body> <div class="myChartDiv"> <canvas id="myChart"></canvas> </div> </body> </html>