chart.html 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>Smart Coffee - dry</title>
  6. <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  7. <!-- 新 Bootstrap4 核心 CSS 文件 -->
  8. <link rel="stylesheet" href="https://cdn.bootcss.com/bootstrap/4.1.0/css/bootstrap.min.css">
  9. <!-- jQuery文件。务必在bootstrap.min.js 之前引入 -->
  10. <script src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
  11. <!-- popper.min.js 用于弹窗、提示、下拉菜单 -->
  12. <script src="https://cdn.bootcss.com/popper.js/1.12.5/umd/popper.min.js"></script>
  13. <!-- 最新的 Bootstrap4 核心 JavaScript 文件 -->
  14. <script src="https://cdn.bootcss.com/bootstrap/4.1.0/js/bootstrap.min.js"></script>
  15. <script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
  16. </head>
  17. <body>
  18. <canvas id="myChart" width="400px" height="400px"></canvas>
  19. <script>
  20. var ctx = document.getElementById('myChart').getContext('2d');
  21. var myChart = new Chart(ctx, {
  22. type: 'bar',
  23. data: {
  24. labels: ['Red', 'Blue', 'Yellow', 'Green', 'Purple', 'Orange'],
  25. datasets: [{
  26. label: '# of Votes',
  27. data: [12, 19, 3, 5, 2, 3],
  28. backgroundColor: [
  29. 'rgba(255, 99, 132, 0.2)',
  30. 'rgba(54, 162, 235, 0.2)',
  31. 'rgba(255, 206, 86, 0.2)',
  32. 'rgba(75, 192, 192, 0.2)',
  33. 'rgba(153, 102, 255, 0.2)',
  34. 'rgba(255, 159, 64, 0.2)'
  35. ],
  36. borderColor: [
  37. 'rgba(255, 99, 132, 1)',
  38. 'rgba(54, 162, 235, 1)',
  39. 'rgba(255, 206, 86, 1)',
  40. 'rgba(75, 192, 192, 1)',
  41. 'rgba(153, 102, 255, 1)',
  42. 'rgba(255, 159, 64, 1)'
  43. ],
  44. borderWidth: 1
  45. }]
  46. },
  47. options: {
  48. scales: {
  49. y: {
  50. beginAtZero: true
  51. }
  52. }
  53. }
  54. });
  55. </script>
  56. </body>
  57. </html>