barandline.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. const colors = ["#5470C6", "#91CC75", "#EE6666"];
  2. export const option = {
  3. color: colors,
  4. tooltip: {
  5. trigger: "axis",
  6. axisPointer: {
  7. type: "cross",
  8. },
  9. },
  10. title: {
  11. text: "Dynamic Data",
  12. },
  13. grid: {
  14. top: "20%",
  15. right: "20%",
  16. bottom: "10%",
  17. containLabel: true, // 包含标签在内
  18. },
  19. toolbox: {
  20. feature: {
  21. dataView: { show: true, readOnly: false },
  22. restore: { show: true },
  23. saveAsImage: { show: true },
  24. },
  25. },
  26. toolbox: {
  27. feature: {
  28. dataView: { show: true, readOnly: false },
  29. magicType: { show: true, type: ["line", "bar"] },
  30. restore: { show: true },
  31. saveAsImage: { show: true },
  32. },
  33. },
  34. legend: {
  35. top: "bottom",
  36. },
  37. xAxis:
  38. // [
  39. {
  40. type: "category",
  41. axisTick: {
  42. alignWithLabel: true,
  43. },
  44. data: [
  45. "Jan",
  46. "Feb",
  47. "Mar",
  48. "Apr",
  49. "May",
  50. "Jun",
  51. "Jul",
  52. "Aug",
  53. "Sep",
  54. "Oct",
  55. "Nov",
  56. "Dec",
  57. ],
  58. },
  59. // ],
  60. yAxis: {
  61. type: "value",
  62. name: "温度",
  63. position: "left",
  64. alignTicks: true,
  65. axisLine: {
  66. show: true,
  67. lineStyle: {
  68. color: colors[2],
  69. },
  70. },
  71. axisLabel: {
  72. formatter: "{value} °C",
  73. },
  74. },
  75. series: [
  76. {
  77. name: "Evaporation",
  78. type: "bar",
  79. data: [
  80. 2.0, 4.9, 7.0, 23.2, 25.6, 76.7, 135.6, 162.2, 32.6, 20.0, 6.4, 3.3,
  81. ],
  82. },
  83. {
  84. name: "Precipitation",
  85. type: "bar",
  86. data: [
  87. 2.6, 5.9, 9.0, 26.4, 28.7, 70.7, 175.6, 182.2, 48.7, 18.8, 6.0, 2.3,
  88. ],
  89. },
  90. {
  91. name: "Temperature",
  92. type: "line",
  93. data: [2.0, 2.2, 3.3, 4.5, 6.3, 10.2, 20.3, 23.4, 23.0, 16.5, 12.0, 6.2],
  94. },
  95. ],
  96. };