border.html 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <!doctype html>
  2. <html>
  3. <head>
  4. <title>Tooltip Border</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. .chart-container {
  14. width: 70%;
  15. margin-left: 40px;
  16. margin-right: 40px;
  17. margin-bottom: 40px;
  18. }
  19. .container {
  20. display: flex;
  21. flex-direction: row;
  22. flex-wrap: wrap;
  23. justify-content: center;
  24. }
  25. </style>
  26. </head>
  27. <body>
  28. <div class="container">
  29. </div>
  30. <script>
  31. function createConfig() {
  32. return {
  33. type: 'line',
  34. data: {
  35. labels: ['January', 'February', 'March', 'April', 'May', 'June', 'July'],
  36. datasets: [{
  37. label: 'Dataset',
  38. borderColor: window.chartColors.red,
  39. backgroundColor: window.chartColors.red,
  40. data: [10, 30, 46, 2, 8, 50, 0],
  41. fill: false,
  42. }]
  43. },
  44. options: {
  45. responsive: true,
  46. title: {
  47. display: true,
  48. text: 'Sample tooltip with border'
  49. },
  50. tooltips: {
  51. position: 'nearest',
  52. mode: 'index',
  53. intersect: false,
  54. yPadding: 10,
  55. xPadding: 10,
  56. caretSize: 8,
  57. backgroundColor: 'rgba(72, 241, 12, 1)',
  58. titleFontColor: window.chartColors.black,
  59. bodyFontColor: window.chartColors.black,
  60. borderColor: 'rgba(0,0,0,1)',
  61. borderWidth: 4
  62. },
  63. }
  64. };
  65. }
  66. window.onload = function() {
  67. var container = document.querySelector('.container');
  68. var div = document.createElement('div');
  69. div.classList.add('chart-container');
  70. var canvas = document.createElement('canvas');
  71. div.appendChild(canvas);
  72. container.appendChild(div);
  73. var ctx = canvas.getContext('2d');
  74. var config = createConfig();
  75. new Chart(ctx, config);
  76. };
  77. </script>
  78. </body>
  79. </html>