base2.html 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <script>
  2. var ctx10 = document.getElementById('bar-yt');
  3. var myChart10 = new Chart(ctx10, {
  4. type: 'bar', //圖表類型
  5. data: {
  6. //標題
  7. labels: [ "{{ keyword }}", '那些足球教我的事'],
  8. datasets: [
  9. {
  10. label: '月搜量',
  11. data: [50, 11],
  12. borderColor: 'rgba(255, 206, 86, 1)',
  13. backgroundColor: 'rgba(255, 206, 86, 1)',
  14. },
  15. {
  16. label: '金額',
  17. data: [40.57, 91.72],
  18. borderColor: 'rgba(255, 99, 132, 1)',
  19. backgroundColor: 'rgba(255, 99, 132, 1)',
  20. },
  21. ],
  22. },
  23. options: {
  24. // indexAxis: 'y',
  25. plugins: {
  26. legend: {
  27. // display: false,
  28. labels: {
  29. padding: 5,
  30. font: {
  31. display: false,
  32. size: 16,
  33. },
  34. },
  35. },
  36. },
  37. scales: {
  38. x: {
  39. ticks: {
  40. font: {
  41. size: 16,
  42. }
  43. },
  44. title: {
  45. display: false,
  46. font: {
  47. family: 'Times',
  48. size: 48,
  49. },
  50. },
  51. },
  52. y: {
  53. title: {
  54. display: true,
  55. },
  56. ticks: {
  57. font: {
  58. size: 16,
  59. }
  60. },
  61. beginAtZero: true,
  62. }
  63. }
  64. }
  65. });
  66. </script>