config-echarts.js 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509
  1. /*
  2. * uCharts®
  3. * 高性能跨平台图表库,支持H5、APP、小程序(微信/支付宝/百度/头条/QQ/360)、Vue、Taro等支持canvas的框架平台
  4. * Copyright (c) 2021 QIUN®秋云 https://www.ucharts.cn All rights reserved.
  5. * Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
  6. * 复制使用请保留本段注释,感谢支持开源!
  7. *
  8. * uCharts®官方网站
  9. * https://www.uCharts.cn
  10. *
  11. * 开源地址:
  12. * https://gitee.com/uCharts/uCharts
  13. *
  14. * uni-app插件市场地址:
  15. * http://ext.dcloud.net.cn/plugin?id=271
  16. *
  17. */
  18. // 通用配置项
  19. // 主题颜色配置:如每个图表类型需要不同主题,请在对应图表类型上更改color属性
  20. const color = ['#1890FF', '#91CB74', '#FAC858', '#EE6666', '#73C0DE', '#3CA272', '#FC8452', '#9A60B4', '#ea7ccc'];
  21. module.exports = {
  22. //demotype为自定义图表类型
  23. "type": ["pie", "ring", "rose", "funnel", "line", "column", "area", "radar", "gauge", "candle", "mix",
  24. "demotype"
  25. ],
  26. //增加自定义图表类型,如果需要categories,请在这里加入您的图表类型例如最后的"demotype"
  27. "categories": ["line", "column", "area", "radar", "gauge", "candle", "mix", "demotype"],
  28. //instance为实例变量承载属性,option为eopts承载属性,不要删除
  29. "instance": {},
  30. "option": {},
  31. //下面是自定义format配置,因除H5端外的其他端无法通过props传递函数,只能通过此属性对应下标的方式来替换
  32. "formatter": {
  33. "tooltipDemo1": function(res) {
  34. let result = ''
  35. for (let i in res) {
  36. if (i == 0) {
  37. result += res[i].axisValueLabel + '年销售额'
  38. }
  39. let value = '--'
  40. if (res[i].data !== null) {
  41. value = res[i].data
  42. }
  43. // #ifdef H5
  44. result += '\n' + res[i].seriesName + ':' + value + ' 万元'
  45. // #endif
  46. // #ifdef APP-PLUS
  47. result += '<br/>' + res[i].marker + res[i].seriesName + ':' + value + ' 万元'
  48. // #endif
  49. }
  50. return result;
  51. },
  52. "legendFormat": function(name) {
  53. return "自定义图例+" + name;
  54. },
  55. "yAxisFormatDemo": function(value, index) {
  56. return value + '元';
  57. },
  58. "seriesFormatDemo": function(res) {
  59. return res.name + '年' + res.value + '元';
  60. },
  61. "yAxisDemo1": function(val) {
  62. if (val > 1000) {
  63. return (val / 1000) + 'k'
  64. } else {
  65. return val
  66. }
  67. },
  68. },
  69. //这里演示了自定义您的图表类型的option,可以随意命名,之后在组件上 type="demotype" 后,组件会调用这个花括号里的option,如果组件上还存在eopts参数,会将demotype与eopts中option合并后渲染图表。
  70. "demotype": {
  71. "color": color,
  72. //在这里填写echarts的option即可
  73. },
  74. // 混合图例
  75. "mix": {
  76. "tooltip": {
  77. "trigger": "axis",
  78. "axisPointer": {
  79. "type": "cross",
  80. "crossStyle": {
  81. "color": "#999",
  82. },
  83. },
  84. },
  85. "color": ["#3ba272", "#fac858"],
  86. "legend": {
  87. "data": []
  88. },
  89. "xAxis": {
  90. "type": 'category',
  91. "axisLabel": {
  92. "color": '#2D405E'
  93. },
  94. "axisLine": {
  95. "lineStyle": {
  96. "color": '#ECF0F7'
  97. }
  98. },
  99. "boundaryGap": true,
  100. "data": []
  101. },
  102. "yAxis": [{
  103. "type": 'value',
  104. "offset": 0,
  105. "axisLabel": {
  106. "color": '#B8C0C8',
  107. },
  108. "axisLine": {
  109. "lineStyle": {
  110. "color": '#ECF0F7'
  111. }
  112. },
  113. },
  114. {
  115. "type": 'value',
  116. "offset": 1,
  117. "axisLabel": {
  118. "color": '#B8C0C8',
  119. },
  120. "axisLine": {
  121. "lineStyle": {
  122. "color": '#ECF0F7'
  123. }
  124. },
  125. },
  126. ],
  127. "seriesTemplate": {},
  128. },
  129. //下面是自定义配置,请添加项目所需的通用配置
  130. "column": {
  131. "color": color,
  132. "title": {
  133. "text": ''
  134. },
  135. "tooltip": {
  136. "trigger": 'axis'
  137. },
  138. "grid": {
  139. "top": 30,
  140. "bottom": 50,
  141. "right": 15,
  142. "left": 40
  143. },
  144. "legend": {
  145. "bottom": 'left',
  146. },
  147. "toolbox": {
  148. "show": false,
  149. },
  150. "xAxis": {
  151. "type": 'category',
  152. "axisLabel": {
  153. "color": '#2D405E'
  154. },
  155. "axisLine": {
  156. "lineStyle": {
  157. "color": '#ECF0F7'
  158. }
  159. },
  160. "boundaryGap": true,
  161. "data": []
  162. },
  163. "yAxis": {
  164. "type": 'value',
  165. "axisTick": {
  166. "show": false,
  167. },
  168. "axisLabel": {
  169. "color": '#B8C0C8'
  170. },
  171. "axisLine": {
  172. "lineStyle": {
  173. "color": '#ECF0F7'
  174. }
  175. },
  176. },
  177. "seriesTemplate": {
  178. "name": '',
  179. "type": 'bar',
  180. "data": [],
  181. "barwidth": 20,
  182. "label": {
  183. "show": true,
  184. "color": "#666666",
  185. "position": 'top',
  186. },
  187. },
  188. },
  189. "line": {
  190. "color": color,
  191. "title": {
  192. "text": ''
  193. },
  194. "tooltip": {
  195. "trigger": 'axis'
  196. },
  197. "grid": {
  198. "top": 30,
  199. "bottom": 50,
  200. "right": 15,
  201. "left": 40
  202. },
  203. "legend": {
  204. "bottom": 'left',
  205. },
  206. "toolbox": {
  207. "show": false,
  208. },
  209. "xAxis": {
  210. "type": 'category',
  211. "axisLabel": {
  212. "color": '#666666'
  213. },
  214. "axisLine": {
  215. "lineStyle": {
  216. "color": '#CCCCCC'
  217. }
  218. },
  219. "boundaryGap": true,
  220. "data": []
  221. },
  222. "yAxis": {
  223. "type": 'value',
  224. "axisTick": {
  225. "show": false,
  226. },
  227. "axisLabel": {
  228. "color": '#666666'
  229. },
  230. "axisLine": {
  231. "lineStyle": {
  232. "color": '#CCCCCC'
  233. }
  234. },
  235. },
  236. "seriesTemplate": {
  237. "name": '',
  238. "type": 'line',
  239. "data": [],
  240. "barwidth": 20,
  241. "label": {
  242. "show": true,
  243. "color": "#666666",
  244. "position": 'top',
  245. },
  246. },
  247. },
  248. "area": {
  249. "color": ["#0668F0", "#F7B500", "#B620E0"],
  250. "title": {
  251. "text": ''
  252. },
  253. "tooltip": {
  254. "trigger": 'axis'
  255. },
  256. "grid": {
  257. "top": 30,
  258. "bottom": 50,
  259. "right": 15,
  260. "left": 40
  261. },
  262. "legend": {
  263. "bottom": 'left',
  264. },
  265. "toolbox": {
  266. "show": false,
  267. },
  268. "xAxis": {
  269. "type": 'category',
  270. "axisLabel": {
  271. "color": '#666666'
  272. },
  273. "axisLine": {
  274. "lineStyle": {
  275. "color": '#CCCCCC'
  276. }
  277. },
  278. "boundaryGap": false,
  279. "data": []
  280. },
  281. "yAxis": {
  282. "type": 'value',
  283. "axisTick": {
  284. "show": false,
  285. },
  286. "axisLabel": {
  287. "color": '#666666'
  288. },
  289. "axisLine": {
  290. "lineStyle": {
  291. "color": '#CCCCCC'
  292. }
  293. },
  294. },
  295. "seriesTemplate": {
  296. "name": '',
  297. "type": 'line',
  298. "smooth": true,
  299. "symbol": "none",
  300. "data": [],
  301. "areaStyle": {
  302. "color": {
  303. "type": "linear",
  304. "x": 0,
  305. "y": 0,
  306. "x2": 0,
  307. "y2": 1,
  308. "colorStops": [{
  309. "offset": 0,
  310. "color": "rgb(198,199,248)", // 0% 处的颜色
  311. },
  312. {
  313. "offset": 1,
  314. "color": "#fff", // 100% 处的颜色
  315. },
  316. ],
  317. "globalCoord": false, // 缺省为 false
  318. },
  319. },
  320. "label": {
  321. "show": true,
  322. "color": "#666666",
  323. "position": 'top',
  324. },
  325. },
  326. },
  327. "pie": {
  328. "color": color,
  329. "title": {
  330. "text": ''
  331. },
  332. "tooltip": {
  333. "trigger": 'item'
  334. },
  335. "grid": {
  336. "top": 40,
  337. "bottom": 30,
  338. "right": 15,
  339. "left": 15
  340. },
  341. "legend": {
  342. "bottom": 'left',
  343. },
  344. "seriesTemplate": {
  345. "name": '',
  346. "type": 'pie',
  347. "data": [],
  348. "radius": '50%',
  349. "label": {
  350. "show": true,
  351. "color": "#666666",
  352. "position": 'top',
  353. },
  354. },
  355. },
  356. "ring": {
  357. "color": color,
  358. "title": {
  359. "text": ''
  360. },
  361. "tooltip": {
  362. "trigger": 'item'
  363. },
  364. "grid": {
  365. "top": 40,
  366. "bottom": 30,
  367. "right": 15,
  368. "left": 15
  369. },
  370. "legend": {
  371. "bottom": 'left',
  372. },
  373. "seriesTemplate": {
  374. "name": '',
  375. "type": 'pie',
  376. "data": [],
  377. "radius": ['40%', '70%'],
  378. "avoidLabelOverlap": false,
  379. "label": {
  380. "show": true,
  381. "color": "#666666",
  382. "position": 'top',
  383. },
  384. "labelLine": {
  385. "show": true
  386. },
  387. },
  388. },
  389. "rose": {
  390. "color": color,
  391. "title": {
  392. "text": ''
  393. },
  394. "tooltip": {
  395. "trigger": 'item'
  396. },
  397. "legend": {
  398. "top": 'bottom'
  399. },
  400. "seriesTemplate": {
  401. "name": '',
  402. "type": 'pie',
  403. "data": [],
  404. "radius": "55%",
  405. "center": ['50%', '50%'],
  406. "rosetype": 'area',
  407. },
  408. },
  409. "funnel": {
  410. "color": color,
  411. "title": {
  412. "text": ''
  413. },
  414. "tooltip": {
  415. "trigger": 'item',
  416. "formatter": "{b} : {c}%"
  417. },
  418. "legend": {
  419. "top": 'bottom'
  420. },
  421. "seriesTemplate": {
  422. "name": '',
  423. "type": 'funnel',
  424. "left": '10%',
  425. "top": 60,
  426. "bottom": 60,
  427. "width": '80%',
  428. "min": 0,
  429. "max": 100,
  430. "minSize": '0%',
  431. "maxSize": '100%',
  432. "sort": 'descending',
  433. "gap": 2,
  434. "label": {
  435. "show": true,
  436. "position": 'inside'
  437. },
  438. "labelLine": {
  439. "length": 10,
  440. "lineStyle": {
  441. "width": 1,
  442. "type": 'solid'
  443. }
  444. },
  445. "itemStyle": {
  446. "bordercolor": '#fff',
  447. "borderwidth": 1
  448. },
  449. "emphasis": {
  450. "label": {
  451. "fontSize": 20
  452. }
  453. },
  454. "data": [],
  455. },
  456. },
  457. "gauge": {
  458. "color": color,
  459. "tooltip": {
  460. "formatter": '{a} <br/>{b} : {c}%'
  461. },
  462. "seriesTemplate": {
  463. "name": '业务指标',
  464. "type": 'gauge',
  465. "detail": {
  466. "formatter": '{value}%'
  467. },
  468. "data": [{
  469. "value": 50,
  470. "name": '完成率'
  471. }]
  472. },
  473. },
  474. "candle": {
  475. "xAxis": {
  476. "data": []
  477. },
  478. "yAxis": {},
  479. "color": color,
  480. "title": {
  481. "text": ''
  482. },
  483. "dataZoom": [{
  484. "type": 'inside',
  485. "xAxisIndex": [0, 1],
  486. "start": 10,
  487. "end": 100
  488. },
  489. {
  490. "show": true,
  491. "xAxisIndex": [0, 1],
  492. "type": 'slider',
  493. "bottom": 10,
  494. "start": 10,
  495. "end": 100
  496. }
  497. ],
  498. "seriesTemplate": {
  499. "name": '',
  500. "type": 'k',
  501. "data": [],
  502. },
  503. }
  504. }