config-echarts.js 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402
  1. // 主题颜色配置:如每个图表类型需要不同主题,请在对应图表类型上更改color属性
  2. const color = ['#1890FF', '#91CB74', '#FAC858', '#EE6666', '#73C0DE', '#3CA272', '#FC8452', '#9A60B4', '#ea7ccc'];
  3. const cfe = {
  4. //demotype为自定义图表类型
  5. "type": ["pie", "ring", "rose", "funnel", "line", "column", "area", "radar", "gauge", "candle", "demotype"],
  6. //增加自定义图表类型,如果需要categories,请在这里加入您的图表类型例如最后的"demotype"
  7. "categories": ["line", "column", "area", "radar", "gauge", "candle", "demotype"],
  8. //instance为实例变量承载属性,option为eopts承载属性,不要删除
  9. "instance": {},
  10. "option": {},
  11. //下面是自定义format配置,因除H5端外的其他端无法通过props传递函数,只能通过此属性对应下标的方式来替换
  12. "formatter": {
  13. "tooltipDemo1": function (res) {
  14. let result = ''
  15. for (let i in res) {
  16. if (i == 0) {
  17. result += res[i].axisValueLabel + '年销售额'
  18. }
  19. let value = '--'
  20. if (res[i].data !== null) {
  21. value = res[i].data
  22. }
  23. // #ifdef H5
  24. result += '\n' + res[i].seriesName + ':' + value + ' 万元'
  25. // #endif
  26. // #ifdef APP-PLUS
  27. result += '<br/>' + res[i].marker + res[i].seriesName + ':' + value + ' 万元'
  28. // #endif
  29. }
  30. return result;
  31. },
  32. legendFormat: function (name) {
  33. return "自定义图例+" + name;
  34. },
  35. yAxisFormatDemo: function (value, index) {
  36. return value + '元';
  37. },
  38. seriesFormatDemo: function (res) {
  39. return res.name + '年' + res.value + '元';
  40. }
  41. },
  42. //这里演示了自定义您的图表类型的option,可以随意命名,之后在组件上 type="demotype" 后,组件会调用这个花括号里的option,如果组件上还存在eopts参数,会将demotype与eopts中option合并后渲染图表。
  43. "demotype": {
  44. "color": color,
  45. //在这里填写echarts的option即可
  46. },
  47. //下面是自定义配置,请添加项目所需的通用配置
  48. "column": {
  49. "color": color,
  50. "title": {
  51. "text": ''
  52. },
  53. "tooltip": {
  54. "trigger": 'axis'
  55. },
  56. "grid": {
  57. "top": 30,
  58. "bottom": 50,
  59. "right": 15,
  60. "left": 40
  61. },
  62. "legend": {
  63. "bottom": 'left',
  64. },
  65. "toolbox": {
  66. "show": false,
  67. },
  68. "xAxis": {
  69. "type": 'category',
  70. "axisLabel": {
  71. "color": '#666666'
  72. },
  73. "axisLine": {
  74. "lineStyle": {
  75. "color": '#CCCCCC'
  76. }
  77. },
  78. "boundaryGap": true,
  79. "data": []
  80. },
  81. "yAxis": {
  82. "type": 'value',
  83. "axisTick": {
  84. "show": false,
  85. },
  86. "axisLabel": {
  87. "color": '#666666'
  88. },
  89. "axisLine": {
  90. "lineStyle": {
  91. "color": '#CCCCCC'
  92. }
  93. },
  94. },
  95. "seriesTemplate": {
  96. "name": '',
  97. "type": 'bar',
  98. "data": [],
  99. "barwidth": 20,
  100. "label": {
  101. "show": true,
  102. "color": "#666666",
  103. "position": 'top',
  104. },
  105. },
  106. },
  107. "line": {
  108. "color": color,
  109. "title": {
  110. "text": ''
  111. },
  112. "tooltip": {
  113. "trigger": 'axis'
  114. },
  115. "grid": {
  116. "top": 30,
  117. "bottom": 50,
  118. "right": 15,
  119. "left": 40
  120. },
  121. "legend": {
  122. "bottom": 'left',
  123. },
  124. "toolbox": {
  125. "show": false,
  126. },
  127. "xAxis": {
  128. "type": 'category',
  129. "axisLabel": {
  130. "color": '#666666'
  131. },
  132. "axisLine": {
  133. "lineStyle": {
  134. "color": '#CCCCCC'
  135. }
  136. },
  137. "boundaryGap": true,
  138. "data": []
  139. },
  140. "yAxis": {
  141. "type": 'value',
  142. "axisTick": {
  143. "show": false,
  144. },
  145. "axisLabel": {
  146. "color": '#666666'
  147. },
  148. "axisLine": {
  149. "lineStyle": {
  150. "color": '#CCCCCC'
  151. }
  152. },
  153. },
  154. "seriesTemplate": {
  155. "name": '',
  156. "type": 'line',
  157. "data": [],
  158. "barwidth": 20,
  159. "label": {
  160. "show": true,
  161. "color": "#666666",
  162. "position": 'top',
  163. },
  164. },
  165. },
  166. "area": {
  167. "color": color,
  168. "title": {
  169. "text": ''
  170. },
  171. "tooltip": {
  172. "trigger": 'axis'
  173. },
  174. "grid": {
  175. "top": 30,
  176. "bottom": 50,
  177. "right": 15,
  178. "left": 40
  179. },
  180. "legend": {
  181. "bottom": 'left',
  182. },
  183. "toolbox": {
  184. "show": false,
  185. },
  186. "xAxis": {
  187. "type": 'category',
  188. "axisLabel": {
  189. "color": '#666666'
  190. },
  191. "axisLine": {
  192. "lineStyle": {
  193. "color": '#CCCCCC'
  194. }
  195. },
  196. "boundaryGap": true,
  197. "data": []
  198. },
  199. "yAxis": {
  200. "type": 'value',
  201. "axisTick": {
  202. "show": false,
  203. },
  204. "axisLabel": {
  205. "color": '#666666'
  206. },
  207. "axisLine": {
  208. "lineStyle": {
  209. "color": '#CCCCCC'
  210. }
  211. },
  212. },
  213. "seriesTemplate": {
  214. "name": '',
  215. "type": 'line',
  216. "data": [],
  217. "areaStyle": {},
  218. "label": {
  219. "show": true,
  220. "color": "#666666",
  221. "position": 'top',
  222. },
  223. },
  224. },
  225. "pie": {
  226. "color": color,
  227. "title": {
  228. "text": ''
  229. },
  230. "tooltip": {
  231. "trigger": 'item'
  232. },
  233. "grid": {
  234. "top": 40,
  235. "bottom": 30,
  236. "right": 15,
  237. "left": 15
  238. },
  239. "legend": {
  240. "bottom": 'left',
  241. },
  242. "seriesTemplate": {
  243. "name": '',
  244. "type": 'pie',
  245. "data": [],
  246. "radius": '50%',
  247. "label": {
  248. "show": true,
  249. "color": "#666666",
  250. "position": 'top',
  251. },
  252. },
  253. },
  254. "ring": {
  255. "color": color,
  256. "title": {
  257. "text": ''
  258. },
  259. "tooltip": {
  260. "trigger": 'item'
  261. },
  262. "grid": {
  263. "top": 40,
  264. "bottom": 30,
  265. "right": 15,
  266. "left": 15
  267. },
  268. "legend": {
  269. "bottom": 'left',
  270. },
  271. "seriesTemplate": {
  272. "name": '',
  273. "type": 'pie',
  274. "data": [],
  275. "radius": ['40%', '70%'],
  276. "avoidLabelOverlap": false,
  277. "label": {
  278. "show": true,
  279. "color": "#666666",
  280. "position": 'top',
  281. },
  282. "labelLine": {
  283. "show": true
  284. },
  285. },
  286. },
  287. "rose": {
  288. "color": color,
  289. "title": {
  290. "text": ''
  291. },
  292. "tooltip": {
  293. "trigger": 'item'
  294. },
  295. "legend": {
  296. "top": 'bottom'
  297. },
  298. "seriesTemplate": {
  299. "name": '',
  300. "type": 'pie',
  301. "data": [],
  302. "radius": "55%",
  303. "center": ['50%', '50%'],
  304. "roseType": 'area',
  305. },
  306. },
  307. "funnel": {
  308. "color": color,
  309. "title": {
  310. "text": ''
  311. },
  312. "tooltip": {
  313. "trigger": 'item',
  314. "formatter": "{b} : {c}%"
  315. },
  316. "legend": {
  317. "top": 'bottom'
  318. },
  319. "seriesTemplate": {
  320. "name": '',
  321. "type": 'funnel',
  322. "left": '10%',
  323. "top": 60,
  324. "bottom": 60,
  325. "width": '80%',
  326. "min": 0,
  327. "max": 100,
  328. "minSize": '0%',
  329. "maxSize": '100%',
  330. "sort": 'descending',
  331. "gap": 2,
  332. "label": {
  333. "show": true,
  334. "position": 'inside'
  335. },
  336. "labelLine": {
  337. "length": 10,
  338. "lineStyle": {
  339. "width": 1,
  340. "type": 'solid'
  341. }
  342. },
  343. "itemStyle": {
  344. "bordercolor": '#fff',
  345. "borderwidth": 1
  346. },
  347. "emphasis": {
  348. "label": {
  349. "fontSize": 20
  350. }
  351. },
  352. "data": [],
  353. },
  354. },
  355. "gauge": {
  356. "color": color,
  357. "tooltip": {
  358. "formatter": '{a} <br/>{b} : {c}%'
  359. },
  360. "seriesTemplate": {
  361. "name": '业务指标',
  362. "type": 'gauge',
  363. "detail": { "formatter": '{value}%' },
  364. "data": [{ "value": 50, "name": '完成率' }]
  365. },
  366. },
  367. "candle": {
  368. "xAxis": {
  369. "data": []
  370. },
  371. "yAxis": {},
  372. "color": color,
  373. "title": {
  374. "text": ''
  375. },
  376. "dataZoom": [{
  377. "type": 'inside',
  378. "xAxisIndex": [0, 1],
  379. "start": 10,
  380. "end": 100
  381. },
  382. {
  383. "show": true,
  384. "xAxisIndex": [0, 1],
  385. "type": 'slider',
  386. "bottom": 10,
  387. "start": 10,
  388. "end": 100
  389. }
  390. ],
  391. "seriesTemplate": {
  392. "name": '',
  393. "type": 'k',
  394. "data": [],
  395. },
  396. }
  397. }
  398. export default cfe;