index.ts 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. import { EChartsOption } from "echarts"
  2. // 颜色预设集合
  3. export const colorPreset = [
  4. {
  5. name: '清新',
  6. color: ['#00a8e1', '#99cc00', '#e30039', '#fcd300', '#800080']
  7. },
  8. {
  9. name: '复古',
  10. color: ['#FFA69E', '#FAE3D9', '#B8F2E6', '#56E39F', '#3A837D']
  11. },
  12. {
  13. name: '商务',
  14. color: ['#194f97', '#555555', '#bd6b08', '#00686b', '#c82d31']
  15. },
  16. {
  17. name: '经典',
  18. color: ['#002c53', '#ffa510', '#0c84c6', '#ffffff', '#f74d4d']
  19. },
  20. {
  21. name: '怀旧',
  22. color: ['#3b6291', '#943c39', '#779043', '#624c7c', '#388498']
  23. }
  24. ]
  25. // 图表默认配置项
  26. export const chartDefaultConfig: EChartsOption = {
  27. // 调色盘-预设颜色
  28. color: colorPreset[0].color,
  29. // 标题
  30. title: {
  31. show: true,
  32. left: "center",
  33. top: 8,
  34. textStyle: {
  35. color: "#FFFFFFFF",
  36. fontSize: 16,
  37. fontWeight: "normal",
  38. },
  39. },
  40. // 图例
  41. legend: {
  42. show: true,
  43. textStyle: {
  44. color: "#FFFFFFFF",
  45. },
  46. top: 32,
  47. bottom: 'auto',
  48. left: 'center',
  49. right: 'auto',
  50. },
  51. // 布局
  52. grid: {
  53. bottom: 34,
  54. right: 20,
  55. left: 20,
  56. top: 60,
  57. },
  58. // x轴
  59. xAxis: {
  60. type: "category",
  61. name: '',
  62. nameLocation: "middle",
  63. nameTruncate: {
  64. ellipsis: "...",
  65. maxWidth: 80
  66. },
  67. nameTextStyle: {
  68. color: '#FFFFFFFF',
  69. fontSize: 12,
  70. fontWeight: 'normal',
  71. fontStyle: 'normal'
  72. },
  73. axisLabel: {
  74. show: true,
  75. color: "#9fadbf",
  76. fontSize: 12,
  77. fontWeight: "normal",
  78. fontStyle: "normal",
  79. },
  80. axisLine: {
  81. show: true,
  82. lineStyle: {
  83. width: 1
  84. }
  85. },
  86. axisTick: {
  87. show: true,
  88. lineStyle: {
  89. width: 1,
  90. color: "#ccc"
  91. }
  92. }
  93. },
  94. // y轴
  95. yAxis: {
  96. splitLine: {
  97. show: true,
  98. lineStyle: {
  99. type: "dashed",
  100. color: "#36485f",
  101. },
  102. },
  103. type: "value",
  104. name: '',
  105. nameLocation: "middle",
  106. nameTruncate: {
  107. ellipsis: "...",
  108. maxWidth: 80
  109. },
  110. nameTextStyle: {
  111. color: '#FFFFFFFF',
  112. fontSize: 12,
  113. fontWeight: 'normal',
  114. fontStyle: 'normal'
  115. },
  116. axisLabel: {
  117. show: true,
  118. color: "#9fadbf",
  119. fontSize: 12,
  120. fontWeight: "normal",
  121. fontStyle: "normal",
  122. rotate: 0,
  123. },
  124. axisLine: {
  125. show: false,
  126. lineStyle: {
  127. width: 1,
  128. color: "#ccc"
  129. }
  130. },
  131. axisTick: {
  132. show: false,
  133. lineStyle: {
  134. width: 1,
  135. color: "#ccc"
  136. }
  137. }
  138. },
  139. // 提示
  140. tooltip: {
  141. show: true,
  142. trigger: "axis",
  143. formatter: "{b} {c}",
  144. // valueFormatter: "(value, dataIndex) => value",
  145. axisPointer: {
  146. type: "line",
  147. },
  148. textStyle: {
  149. color: "#000000FF",
  150. fontSize: 12,
  151. fontWeight: "normal",
  152. fontStyle: "normal",
  153. },
  154. padding: 10,
  155. borderWidth: 1,
  156. borderColor: "#ccc",
  157. borderRadius: 4,
  158. backgroundColor: "#FFFFFFFF",
  159. extraCssText: "",
  160. }
  161. }
  162. // 组件容器基本设置
  163. export const containerDefaultConfig = {
  164. /* ===================================== 通用容器样式 ============================================ */
  165. style: {
  166. background: {
  167. type: "color", // none, color, image
  168. color: "rgba(0, 0, 0, 0.1)",
  169. image: "",
  170. fillType: "",
  171. },
  172. border: {
  173. type: "none",
  174. color: "#000",
  175. width: 0,
  176. },
  177. borderRadius: {
  178. type: "all", // all, custom
  179. value: 2, // 整体圆角值
  180. unit: "px", // 单位
  181. units: ["px", "%"], // 单位列表
  182. topLeft: 0,
  183. topRight: 0,
  184. bottomLeft: 0,
  185. bottomRight: 0,
  186. },
  187. boxShadow: {
  188. enabled: false,
  189. color: "#000",
  190. offsetX: 0,
  191. offsetY: 0,
  192. blurRadius: 0,
  193. spreadRadius: 0,
  194. inset: false,
  195. },
  196. backdropFilter: {
  197. enabled: false,
  198. blur: 0,
  199. }
  200. },
  201. /* ===================================== 通用容器属性 ============================================ */
  202. props: {
  203. width: 0,
  204. height: 0,
  205. x: 0,
  206. y: 0,
  207. paddingLeft: 0,
  208. paddingRight: 0,
  209. paddingTop: 0,
  210. paddingBottom: 0,
  211. rotateX: 0,
  212. rotateY: 0,
  213. rotateZ: 0,
  214. opacity: 1,
  215. },
  216. };