gridlines-style.html 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <!doctype html>
  2. <html>
  3. <head>
  4. <title>Grid Lines Style Settings</title>
  5. <script src="../../dist/Chart.bundle.js"></script>
  6. <script src="../utils.js"></script>
  7. <style>
  8. canvas{
  9. -moz-user-select: none;
  10. -webkit-user-select: none;
  11. -ms-user-select: none;
  12. }
  13. </style>
  14. </head>
  15. <body>
  16. <div style="width:75%;">
  17. <canvas id="canvas"></canvas>
  18. </div>
  19. <script>
  20. var config = {
  21. type: 'line',
  22. data: {
  23. labels: ['January', 'February', 'March', 'April', 'May', 'June', 'July'],
  24. datasets: [{
  25. label: 'My First dataset',
  26. backgroundColor: window.chartColors.red,
  27. borderColor: window.chartColors.red,
  28. data: [10, 30, 39, 20, 25, 34, -10],
  29. fill: false,
  30. }, {
  31. label: 'My Second dataset',
  32. fill: false,
  33. backgroundColor: window.chartColors.blue,
  34. borderColor: window.chartColors.blue,
  35. data: [18, 33, 22, 19, 11, 39, 30],
  36. }]
  37. },
  38. options: {
  39. responsive: true,
  40. title: {
  41. display: true,
  42. text: 'Grid Line Settings'
  43. },
  44. scales: {
  45. yAxes: [{
  46. gridLines: {
  47. drawBorder: false,
  48. color: ['pink', 'red', 'orange', 'yellow', 'green', 'blue', 'indigo', 'purple']
  49. },
  50. ticks: {
  51. min: 0,
  52. max: 100,
  53. stepSize: 10
  54. }
  55. }]
  56. }
  57. }
  58. };
  59. window.onload = function() {
  60. var ctx = document.getElementById('canvas').getContext('2d');
  61. window.myLine = new Chart(ctx, config);
  62. };
  63. </script>
  64. </body>
  65. </html>