chartOption.js 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. import * as echarts from "echarts";
  2. const commonxAxis = {
  3. axisLabel: { color: '#9F9F9F' },
  4. axisLine: { lineStyle: { color: 'rgba(185, 185, 185, 0.12)' } },
  5. }
  6. const commonyAxis = {
  7. splitLine: { lineStyle: { color: 'rgba(185, 185, 185, 0.12)' } },
  8. axisLabel: {
  9. color: "#9F9F9F",
  10. },
  11. }
  12. export const pieOption = {
  13. tooltip: {
  14. trigger: 'item',
  15. textStyle: {
  16. color: "#1D2129",
  17. fontSize: 11,
  18. },
  19. formatter: function (params) {
  20. const data = params.data;
  21. const total = 3774;
  22. const percent = (data.value / total * 100).toFixed(2);
  23. return `${params.marker}${data.name}     ${percent}%     ${data.value}亩`;
  24. }
  25. },
  26. title: {
  27. text: '总种植面积(亩)',
  28. subtext: '1000',
  29. x: '49%',
  30. y: '39%',
  31. textAlign: 'center',
  32. textStyle: {
  33. fontSize: 11,
  34. fontWeight: 'normal',
  35. color: '#FFFFFF'
  36. },
  37. subtextStyle: {
  38. fontSize: 13,
  39. fontWeight: 'normal',
  40. color: '#FFFFFF'
  41. }
  42. },
  43. color: ['#2199F8', '#14C9C9', '#FFCC4B', '#8F46F4', '#FF7878', '#9FDB1D'],
  44. series: [
  45. {
  46. name: '种植作物',
  47. type: 'pie',
  48. radius: ['56%', '86%'],
  49. label: {
  50. show: false,
  51. position: 'center'
  52. },
  53. labelLine: {
  54. show: false
  55. },
  56. data: [
  57. { value: 1048, name: '水稻' },
  58. { value: 735, name: '小麦' },
  59. { value: 580, name: '猫草' },
  60. { value: 484, name: '中草药' },
  61. { value: 300, name: '蔬菜' },
  62. { value: 300, name: '荔枝' },
  63. ]
  64. }
  65. ]
  66. };
  67. export const barOption = {
  68. grid: {
  69. top: 20,
  70. left: 10,
  71. right: 10,
  72. bottom: 10,
  73. containLabel: true,
  74. },
  75. xAxis: {
  76. type: 'category',
  77. ...commonxAxis,
  78. data: ['从化区', '增城区', '花都区', '番禺区', '南沙区', '从化区', '荔湾区']
  79. },
  80. yAxis: {
  81. type: 'value',
  82. ...commonyAxis,
  83. axisLabel: {
  84. formatter: "{value}%",
  85. color: "#9F9F9F",
  86. },
  87. },
  88. series: [
  89. {
  90. data: [50, 20, 15, 58, 7, 28, 13],
  91. type: 'bar',
  92. barWidth: 10,
  93. itemStyle: {
  94. borderRadius: [8, 8, 0, 0],
  95. color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
  96. {
  97. offset: 0,
  98. color: '#FFD489',
  99. },
  100. {
  101. offset: 1,
  102. color: '#996324',
  103. },
  104. ]),
  105. },
  106. }
  107. ]
  108. }
  109. export const lineOption = {
  110. tooltip: {
  111. trigger: 'axis'
  112. },
  113. grid: {
  114. top: 20,
  115. left: 10,
  116. right: 10,
  117. bottom: 10,
  118. containLabel: true,
  119. },
  120. xAxis: {
  121. ...commonxAxis,
  122. type: 'category',
  123. boundaryGap: false,
  124. data: ['2023-6', '2023-12', '2024-6', '2024-12', '2025-6', '2025-12']
  125. },
  126. yAxis: {
  127. ...commonyAxis,
  128. type: 'value'
  129. },
  130. series: [
  131. {
  132. name: '粮食',
  133. type: 'line',
  134. smooth: true,
  135. showSymbol: false,
  136. itemStyle: {
  137. color: '#178B00'
  138. },
  139. lineStyle: {
  140. color: '#178B00'
  141. },
  142. data: [250, 232, 221, 294, 310, 380]
  143. },
  144. {
  145. name: '果类',
  146. type: 'line',
  147. smooth: true,
  148. showSymbol: false,
  149. itemStyle: {
  150. color: '#2199F8'
  151. },
  152. lineStyle: {
  153. color: '#2199F8'
  154. },
  155. data: [220, 182, 191, 234, 290, 330]
  156. },
  157. {
  158. name: '蔬菜',
  159. type: 'line',
  160. smooth: true,
  161. showSymbol: false,
  162. itemStyle: {
  163. color: '#FAA53D'
  164. },
  165. lineStyle: {
  166. color: '#FAA53D'
  167. },
  168. data: [120, 132, 101, 134, 90, 230]
  169. },
  170. ]
  171. };