line-styles.html 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. <!doctype html>
  2. <html>
  3. <head>
  4. <title>Line Styles</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: 'Unfilled',
  26. fill: false,
  27. backgroundColor: window.chartColors.blue,
  28. borderColor: window.chartColors.blue,
  29. data: [
  30. randomScalingFactor(),
  31. randomScalingFactor(),
  32. randomScalingFactor(),
  33. randomScalingFactor(),
  34. randomScalingFactor(),
  35. randomScalingFactor(),
  36. randomScalingFactor()
  37. ],
  38. }, {
  39. label: 'Dashed',
  40. fill: false,
  41. backgroundColor: window.chartColors.green,
  42. borderColor: window.chartColors.green,
  43. borderDash: [5, 5],
  44. data: [
  45. randomScalingFactor(),
  46. randomScalingFactor(),
  47. randomScalingFactor(),
  48. randomScalingFactor(),
  49. randomScalingFactor(),
  50. randomScalingFactor(),
  51. randomScalingFactor()
  52. ],
  53. }, {
  54. label: 'Filled',
  55. backgroundColor: window.chartColors.red,
  56. borderColor: window.chartColors.red,
  57. data: [
  58. randomScalingFactor(),
  59. randomScalingFactor(),
  60. randomScalingFactor(),
  61. randomScalingFactor(),
  62. randomScalingFactor(),
  63. randomScalingFactor(),
  64. randomScalingFactor()
  65. ],
  66. fill: true,
  67. }]
  68. },
  69. options: {
  70. responsive: true,
  71. title: {
  72. display: true,
  73. text: 'Chart.js Line Chart'
  74. },
  75. tooltips: {
  76. mode: 'index',
  77. intersect: false,
  78. },
  79. hover: {
  80. mode: 'nearest',
  81. intersect: true
  82. },
  83. scales: {
  84. xAxes: [{
  85. display: true,
  86. scaleLabel: {
  87. display: true,
  88. labelString: 'Month'
  89. }
  90. }],
  91. yAxes: [{
  92. display: true,
  93. scaleLabel: {
  94. display: true,
  95. labelString: 'Value'
  96. }
  97. }]
  98. }
  99. }
  100. };
  101. window.onload = function() {
  102. var ctx = document.getElementById('canvas').getContext('2d');
  103. window.myLine = new Chart(ctx, config);
  104. };
  105. </script>
  106. </body>
  107. </html>