index.ts 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  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. fontStyle: "normal"
  39. },
  40. },
  41. // 图例
  42. legend: {
  43. show: true,
  44. textStyle: {
  45. color: "#FFFFFFFF",
  46. },
  47. top: 32,
  48. bottom: 'auto',
  49. left: 'center',
  50. right: 'auto',
  51. },
  52. // 布局
  53. grid: {
  54. bottom: 34,
  55. right: 20,
  56. left: 20,
  57. top: 60,
  58. },
  59. // x轴
  60. xAxis: {
  61. type: "category",
  62. name: '',
  63. nameLocation: "middle",
  64. nameTruncate: {
  65. ellipsis: "...",
  66. maxWidth: 80
  67. },
  68. nameTextStyle: {
  69. color: '#FFFFFFFF',
  70. fontSize: 12,
  71. fontWeight: 'normal',
  72. fontStyle: 'normal'
  73. },
  74. axisLabel: {
  75. show: true,
  76. color: "#9fadbf",
  77. fontSize: 12,
  78. fontWeight: "normal",
  79. fontStyle: "normal",
  80. },
  81. axisLine: {
  82. show: true,
  83. lineStyle: {
  84. width: 1
  85. }
  86. },
  87. axisTick: {
  88. show: true,
  89. lineStyle: {
  90. width: 1,
  91. color: "#ccc"
  92. }
  93. }
  94. },
  95. // y轴
  96. yAxis: {
  97. splitLine: {
  98. show: true,
  99. lineStyle: {
  100. type: "dashed",
  101. color: "#36485f",
  102. },
  103. },
  104. type: "value",
  105. name: '',
  106. nameLocation: "middle",
  107. nameTruncate: {
  108. ellipsis: "...",
  109. maxWidth: 80
  110. },
  111. nameTextStyle: {
  112. color: '#FFFFFFFF',
  113. fontSize: 12,
  114. fontWeight: 'normal',
  115. fontStyle: 'normal'
  116. },
  117. axisLabel: {
  118. show: true,
  119. color: "#9fadbf",
  120. fontSize: 12,
  121. fontWeight: "normal",
  122. fontStyle: "normal",
  123. rotate: 0,
  124. },
  125. axisLine: {
  126. show: false,
  127. lineStyle: {
  128. width: 1,
  129. color: "#ccc"
  130. }
  131. },
  132. axisTick: {
  133. show: false,
  134. lineStyle: {
  135. width: 1,
  136. color: "#ccc"
  137. }
  138. }
  139. },
  140. // 提示
  141. tooltip: {
  142. show: true,
  143. trigger: "axis",
  144. formatter: "{b} {c}",
  145. // valueFormatter: "(value, dataIndex) => value",
  146. axisPointer: {
  147. type: "line",
  148. },
  149. textStyle: {
  150. color: "#000000FF",
  151. fontSize: 12,
  152. fontWeight: "normal",
  153. fontStyle: "normal",
  154. },
  155. padding: 10,
  156. borderWidth: 1,
  157. borderColor: "#ccc",
  158. borderRadius: 4,
  159. backgroundColor: "#FFFFFFFF",
  160. extraCssText: "",
  161. }
  162. }
  163. // 组件容器基本设置
  164. export const containerDefaultConfig = {
  165. /* ===================================== 通用容器样式 ============================================ */
  166. style: {
  167. background: {
  168. type: "color", // none, color, image
  169. color: "rgba(0, 0, 0, 0.1)",
  170. image: "",
  171. fillType: "",
  172. },
  173. border: {
  174. type: "none",
  175. color: "#000",
  176. width: 0,
  177. },
  178. borderRadius: {
  179. type: "all", // all, custom
  180. value: 2, // 整体圆角值
  181. unit: "px", // 单位
  182. units: ["px", "%"], // 单位列表
  183. topLeft: 0,
  184. topRight: 0,
  185. bottomLeft: 0,
  186. bottomRight: 0,
  187. },
  188. boxShadow: {
  189. enabled: false,
  190. color: "#000",
  191. offsetX: 0,
  192. offsetY: 0,
  193. blurRadius: 0,
  194. spreadRadius: 0,
  195. inset: false,
  196. },
  197. backdropFilter: {
  198. enabled: false,
  199. blur: 0,
  200. }
  201. },
  202. /* ===================================== 通用容器属性 ============================================ */
  203. props: {
  204. width: 0,
  205. height: 0,
  206. x: 0,
  207. y: 0,
  208. paddingLeft: 0,
  209. paddingRight: 0,
  210. paddingTop: 0,
  211. paddingBottom: 0,
  212. rotateX: 0,
  213. rotateY: 0,
  214. rotateZ: 0,
  215. opacity: 1,
  216. },
  217. };