point-sizes.html 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. <!doctype html>
  2. <html>
  3. <head>
  4. <title>Different Point Sizes</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: 'dataset - big points',
  26. data: [
  27. randomScalingFactor(),
  28. randomScalingFactor(),
  29. randomScalingFactor(),
  30. randomScalingFactor(),
  31. randomScalingFactor(),
  32. randomScalingFactor(),
  33. randomScalingFactor()
  34. ],
  35. backgroundColor: window.chartColors.red,
  36. borderColor: window.chartColors.red,
  37. fill: false,
  38. borderDash: [5, 5],
  39. pointRadius: 15,
  40. pointHoverRadius: 10,
  41. }, {
  42. label: 'dataset - individual point sizes',
  43. data: [
  44. randomScalingFactor(),
  45. randomScalingFactor(),
  46. randomScalingFactor(),
  47. randomScalingFactor(),
  48. randomScalingFactor(),
  49. randomScalingFactor(),
  50. randomScalingFactor()
  51. ],
  52. backgroundColor: window.chartColors.blue,
  53. borderColor: window.chartColors.blue,
  54. fill: false,
  55. borderDash: [5, 5],
  56. pointRadius: [2, 4, 6, 18, 0, 12, 20],
  57. }, {
  58. label: 'dataset - large pointHoverRadius',
  59. data: [
  60. randomScalingFactor(),
  61. randomScalingFactor(),
  62. randomScalingFactor(),
  63. randomScalingFactor(),
  64. randomScalingFactor(),
  65. randomScalingFactor(),
  66. randomScalingFactor()
  67. ],
  68. backgroundColor: window.chartColors.green,
  69. borderColor: window.chartColors.green,
  70. fill: false,
  71. pointHoverRadius: 30,
  72. }, {
  73. label: 'dataset - large pointHitRadius',
  74. data: [
  75. randomScalingFactor(),
  76. randomScalingFactor(),
  77. randomScalingFactor(),
  78. randomScalingFactor(),
  79. randomScalingFactor(),
  80. randomScalingFactor(),
  81. randomScalingFactor()
  82. ],
  83. backgroundColor: window.chartColors.yellow,
  84. borderColor: window.chartColors.yellow,
  85. fill: false,
  86. pointHitRadius: 20,
  87. }]
  88. },
  89. options: {
  90. responsive: true,
  91. legend: {
  92. position: 'bottom',
  93. },
  94. hover: {
  95. mode: 'index'
  96. },
  97. scales: {
  98. xAxes: [{
  99. display: true,
  100. scaleLabel: {
  101. display: true,
  102. labelString: 'Month'
  103. }
  104. }],
  105. yAxes: [{
  106. display: true,
  107. scaleLabel: {
  108. display: true,
  109. labelString: 'Value'
  110. }
  111. }]
  112. },
  113. title: {
  114. display: true,
  115. text: 'Chart.js Line Chart - Different point sizes'
  116. }
  117. }
  118. };
  119. window.onload = function() {
  120. var ctx = document.getElementById('canvas').getContext('2d');
  121. window.myLine = new Chart(ctx, config);
  122. };
  123. </script>
  124. </body>
  125. </html>