Javascript examples for Chart.js:Line Chart
ChartJS to display line chart with single element as a line
<html lang="en"> <head> <title>Chart.js Horizontal line on line chart with 1 point</title> </head> <body translate="no"> <div style="width: 75%"> <canvas id="canvas"></canvas> </div> <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.5.0/Chart.min.js"></script> <script src="https://rawgit.com/chartjs/chartjs-plugin-annotation/master/chartjs-plugin-annotation.js"></script> <script> window.chartColors = {/*w w w . ja v a 2 s . c o m*/ red: 'rgb(255, 99, 132)', orange: 'rgb(255, 159, 64)', yellow: 'rgb(255, 205, 86)', green: 'rgb(75, 192, 192)', blue: 'rgb(54, 162, 235)', purple: 'rgb(153, 102, 255)', grey: 'rgb(231,233,237)' }; var ctx = document.getElementById("canvas").getContext("2d"); var myChart = new Chart(ctx, { type: 'line', data: { labels: ["January"], datasets: [{ label: 'Dataset 1', borderColor: window.chartColors.blue, borderWidth: 2, fill: false, data: [5] }] }, options: { responsive: true, title: { display: true, text: 'Chart.js Stacked Bar and Unstacked Line Combo Chart' }, tooltips: { mode: 'index', intersect: true }, annotation: { annotations: [{ type: 'line', mode: 'horizontal', scaleID: 'y-axis-0', value: 5, borderColor: 'rgb(75, 192, 192)', borderWidth: 4, label: { enabled: false, content: 'Test label' } }] } } }); //# sourceURL=pen.js </script> </body> </html>