config-ucharts.js 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608
  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. // 主题颜色配置:如每个图表类型需要不同主题,请在对应图表类型上更改color属性
  19. const color = ['#1890FF', '#91CB74', '#FAC858', '#EE6666', '#73C0DE', '#3CA272', '#FC8452', '#9A60B4', '#ea7ccc'];
  20. //事件转换函数,主要用作格式化x轴为时间轴,根据需求自行修改
  21. const formatDateTime = (timeStamp, returnType)=>{
  22. var date = new Date();
  23. date.setTime(timeStamp * 1000);
  24. var y = date.getFullYear();
  25. var m = date.getMonth() + 1;
  26. m = m < 10 ? ('0' + m) : m;
  27. var d = date.getDate();
  28. d = d < 10 ? ('0' + d) : d;
  29. var h = date.getHours();
  30. h = h < 10 ? ('0' + h) : h;
  31. var minute = date.getMinutes();
  32. var second = date.getSeconds();
  33. minute = minute < 10 ? ('0' + minute) : minute;
  34. second = second < 10 ? ('0' + second) : second;
  35. if(returnType == 'full'){return y + '-' + m + '-' + d + ' '+ h +':' + minute + ':' + second;}
  36. if(returnType == 'y-m-d'){return y + '-' + m + '-' + d;}
  37. if(returnType == 'h:m'){return h +':' + minute;}
  38. if(returnType == 'h:m:s'){return h +':' + minute +':' + second;}
  39. return [y, m, d, h, minute, second];
  40. }
  41. const cfu = {
  42. //demotype为自定义图表类型,一般不需要自定义图表类型,只需要改根节点上对应的类型即可
  43. "type":["pie","ring","rose","word","funnel","map","arcbar","line","column","bar","area","radar","gauge","candle","mix","tline","tarea","scatter","bubble","demotype"],
  44. "range":["饼状图","圆环图","玫瑰图","词云图","漏斗图","地图","圆弧进度条","折线图","柱状图","条状图","区域图","雷达图","仪表盘","K线图","混合图","时间轴折线","时间轴区域","散点图","气泡图","自定义类型"],
  45. //增加自定义图表类型,如果需要categories,请在这里加入您的图表类型,例如最后的"demotype"
  46. //自定义类型时需要注意"tline","tarea","scatter","bubble"等时间轴(矢量x轴)类图表,没有categories,不需要加入categories
  47. "categories":["line","column","bar","area","radar","gauge","candle","mix","demotype"],
  48. //instance为实例变量承载属性,不要删除
  49. "instance":{},
  50. //option为opts及eopts承载属性,不要删除
  51. "option":{},
  52. //下面是自定义format配置,因除H5端外的其他端无法通过props传递函数,只能通过此属性对应下标的方式来替换
  53. "formatter":{
  54. "moreDataShow":function(val,index,opts,series){
  55. if(series.otherData[index] == 0 && val == 0){
  56. return ''
  57. }else {
  58. return series.otherData[index] +'亿' + ';同比增长' + val + '%'
  59. }
  60. },
  61. "exceptZero":function(val,index,opts,series){
  62. if(val == 0){
  63. return ''
  64. }else {
  65. return val + '';
  66. }
  67. },
  68. "yAxisDemo2":function(val){return val.toFixed(2)},
  69. "fix1":function(val,index,opts,series){return series.otherData[index] + '%'},
  70. "xAxisDemo1":function(val){return val+'年'},
  71. "fix0":function(val){return Math.ceil(val)},
  72. "lineRaito":function(val){return val.toFixed(2) +'%'},
  73. "lineRaitoY":function(val){return val.toFixed(1) +'%'},
  74. "xAxisDemo2":function(val){return formatDateTime(val,'h:m')},
  75. "seriesDemo1":function(val){return val+'元'},
  76. "tooltipDemo1":function(item, category, index, opts){
  77. if(index==0){
  78. return '随便用'+item.data+'年'
  79. }else{
  80. return '其他我没改'+item.data+'天'
  81. }
  82. },
  83. "pieDemo":function(val, index, series){
  84. if(index !== undefined){
  85. return series[index].name+':'+series[index].data+'元'
  86. }
  87. },
  88. },
  89. //这里演示了自定义您的图表类型的option,可以随意命名,之后在组件上 type="demotype" 后,组件会调用这个花括号里的option,如果组件上还存在opts参数,会将demotype与opts中option合并后渲染图表。
  90. "demotype":{
  91. //我这里把曲线图当做了自定义图表类型,您可以根据需要随意指定类型或配置
  92. "type": "line",
  93. "color": color,
  94. "padding": [15,10,0,15],
  95. "xAxis": {
  96. "disableGrid": true,
  97. },
  98. "yAxis": {
  99. "gridType": "dash",
  100. "dashLength": 2,
  101. },
  102. "legend": {
  103. },
  104. "extra": {
  105. "line": {
  106. "type": "curve",
  107. "width": 2
  108. },
  109. }
  110. },
  111. //下面是自定义配置,请添加项目所需的通用配置
  112. "pie":{
  113. "type": "pie",
  114. "color": color,
  115. "padding": [5,5,5,5],
  116. "extra": {
  117. "pie": {
  118. "activeOpacity": 0.5,
  119. "activeRadius": 10,
  120. "offsetAngle": 0,
  121. "labelWidth": 15,
  122. "border": true,
  123. "borderWidth": 3,
  124. "borderColor": "#FFFFFF"
  125. },
  126. }
  127. },
  128. "ring":{
  129. "type": "ring",
  130. "color": color,
  131. "padding": [5,5,5,5],
  132. "rotate": false,
  133. "dataLabel": true,
  134. "legend": {
  135. "show": true,
  136. "position": "right",
  137. "lineHeight": 25,
  138. },
  139. "title": {
  140. "name": "收益率",
  141. "fontSize": 15,
  142. "color": "#666666"
  143. },
  144. "subtitle": {
  145. "name": "70%",
  146. "fontSize": 25,
  147. "color": "#7cb5ec"
  148. },
  149. "extra": {
  150. "ring": {
  151. "ringWidth":30,
  152. "activeOpacity": 0.5,
  153. "activeRadius": 10,
  154. "offsetAngle": 0,
  155. "labelWidth": 15,
  156. "border": true,
  157. "borderWidth": 3,
  158. "borderColor": "#FFFFFF"
  159. },
  160. },
  161. },
  162. "rose":{
  163. "type": "rose",
  164. "color": color,
  165. "padding": [5,5,5,5],
  166. "legend": {
  167. "show": true,
  168. "position": "left",
  169. "lineHeight": 25,
  170. },
  171. "extra": {
  172. "rose": {
  173. "type": "area",
  174. "minRadius": 50,
  175. "activeOpacity": 0.5,
  176. "activeRadius": 10,
  177. "offsetAngle": 0,
  178. "labelWidth": 15,
  179. "border": false,
  180. "borderWidth": 2,
  181. "borderColor": "#FFFFFF"
  182. },
  183. }
  184. },
  185. "word":{
  186. "type": "word",
  187. "color": color,
  188. "extra": {
  189. "word": {
  190. "type": "normal",
  191. "autoColors": false
  192. }
  193. }
  194. },
  195. "funnel":{
  196. "type": "funnel",
  197. "color": color,
  198. "padding": [15,15,0,15],
  199. "extra": {
  200. "funnel": {
  201. "activeOpacity": 0.3,
  202. "activeWidth": 10,
  203. "border": true,
  204. "borderWidth": 2,
  205. "borderColor": "#FFFFFF",
  206. "fillOpacity": 1,
  207. "labelAlign": "right"
  208. },
  209. }
  210. },
  211. "map":{
  212. "type": "map",
  213. "color": color,
  214. "padding": [0,0,0,0],
  215. "dataLabel": true,
  216. "extra": {
  217. "map": {
  218. "border": true,
  219. "borderWidth": 1,
  220. "borderColor": "#666666",
  221. "fillOpacity": 0.6,
  222. "activeBorderColor": "#F04864",
  223. "activeFillColor": "#FACC14",
  224. "activeFillOpacity": 1
  225. },
  226. }
  227. },
  228. "arcbar":{
  229. "type": "arcbar",
  230. "color": color,
  231. "title": {
  232. "name": "百分比",
  233. "fontSize": 25,
  234. "color": "#00FF00"
  235. },
  236. "subtitle": {
  237. "name": "默认标题",
  238. "fontSize": 15,
  239. "color": "#666666"
  240. },
  241. "extra": {
  242. "arcbar": {
  243. "type": "default",
  244. "width": 12,
  245. "backgroundColor": "#E9E9E9",
  246. "startAngle": 0.75,
  247. "endAngle": 0.25,
  248. "gap": 2
  249. }
  250. }
  251. },
  252. "line":{
  253. "type": "line",
  254. "color": color,
  255. "padding": [15,10,0,15],
  256. "xAxis": {
  257. "disableGrid": true,
  258. },
  259. "yAxis": {
  260. "gridType": "dash",
  261. "dashLength": 2,
  262. },
  263. "legend": {
  264. },
  265. "extra": {
  266. "line": {
  267. "type": "straight",
  268. "width": 2
  269. },
  270. }
  271. },
  272. "tline":{
  273. "type": "line",
  274. "color": color,
  275. "padding": [15,10,0,15],
  276. "xAxis": {
  277. "disableGrid": false,
  278. "boundaryGap":"justify",
  279. },
  280. "yAxis": {
  281. "gridType": "dash",
  282. "dashLength": 2,
  283. "data":[
  284. {
  285. "min":0,
  286. "max":80
  287. }
  288. ]
  289. },
  290. "legend": {
  291. },
  292. "extra": {
  293. "line": {
  294. "type": "curve",
  295. "width": 2
  296. },
  297. }
  298. },
  299. "tarea":{
  300. "type": "area",
  301. "color": color,
  302. "padding": [15,10,0,15],
  303. "xAxis": {
  304. "disableGrid": true,
  305. "boundaryGap":"justify",
  306. },
  307. "yAxis": {
  308. "gridType": "dash",
  309. "dashLength": 2,
  310. "data":[
  311. {
  312. "min":0,
  313. "max":80
  314. }
  315. ]
  316. },
  317. "legend": {
  318. },
  319. "extra": {
  320. "area": {
  321. "type": "curve",
  322. "opacity": 0.2,
  323. "addLine": true,
  324. "width": 2,
  325. "gradient": true
  326. },
  327. }
  328. },
  329. "column":{
  330. "type": "column",
  331. "color": color,
  332. "padding": [15,15,0,5],
  333. "xAxis": {
  334. "disableGrid": true,
  335. },
  336. "yAxis": {
  337. "data":[{"min":0}]
  338. },
  339. "legend": {
  340. },
  341. "extra": {
  342. "column": {
  343. "type": "group",
  344. "width": 30,
  345. "meterBorde": 1,
  346. "meterFillColor": "#FFFFFF",
  347. "activeBgColor": "#000000",
  348. "activeBgOpacity": 0.08
  349. },
  350. }
  351. },
  352. "bar":{
  353. "type": "bar",
  354. "color": color,
  355. "padding": [15,30,0,5],
  356. "xAxis": {
  357. "boundaryGap":"justify",
  358. "disableGrid":false,
  359. "min":0,
  360. "axisLine":false,
  361. },
  362. "yAxis": {
  363. "data": [
  364. {
  365. "type": "categories",
  366. "fontSize": 10,
  367. "textAlign": "left",
  368. }
  369. ]
  370. },
  371. "legend": {
  372. },
  373. "extra": {
  374. "bar": {
  375. "type": "group",
  376. "width": 30,
  377. "meterBorde": 1,
  378. "meterFillColor": "#FFFFFF",
  379. "activeBgColor": "#000000",
  380. "activeBgOpacity": 0.08
  381. },
  382. }
  383. },
  384. "area":{
  385. "type": "area",
  386. "color": color,
  387. "padding": [15,15,0,15],
  388. "xAxis": {
  389. "disableGrid": true,
  390. },
  391. "yAxis": {
  392. "gridType": "dash",
  393. "dashLength": 2,
  394. },
  395. "legend": {
  396. },
  397. "extra": {
  398. "area": {
  399. "type": "straight",
  400. "opacity": 0.2,
  401. "addLine": true,
  402. "width": 2,
  403. "gradient": false
  404. },
  405. }
  406. },
  407. "radar":{
  408. "type": "radar",
  409. "color": color,
  410. "padding": [5,5,5,5],
  411. "dataLabel": false,
  412. "legend": {
  413. "show": true,
  414. "position": "right",
  415. "lineHeight": 25,
  416. },
  417. "extra": {
  418. "radar": {
  419. "gridType": "radar",
  420. "gridColor": "#CCCCCC",
  421. "gridCount": 3,
  422. "opacity": 0.2,
  423. "max": 200
  424. },
  425. }
  426. },
  427. "gauge":{
  428. "type": "gauge",
  429. "color": color,
  430. "title": {
  431. "name": "66Km/H",
  432. "fontSize": 25,
  433. "color": "#2fc25b",
  434. "offsetY": 50
  435. },
  436. "subtitle": {
  437. "name": "实时速度",
  438. "fontSize": 15,
  439. "color": "#1890ff",
  440. "offsetY": -50
  441. },
  442. "extra": {
  443. "gauge": {
  444. "type": "default",
  445. "width": 30,
  446. "labelColor": "#666666",
  447. "startAngle": 0.75,
  448. "endAngle": 0.25,
  449. "startNumber": 0,
  450. "endNumber": 100,
  451. "labelFormat": "",
  452. "splitLine": {
  453. "fixRadius": 0,
  454. "splitNumber": 10,
  455. "width": 30,
  456. "color": "#FFFFFF",
  457. "childNumber": 5,
  458. "childWidth": 12
  459. },
  460. "pointer": {
  461. "width": 24,
  462. "color": "auto"
  463. }
  464. }
  465. }
  466. },
  467. "candle":{
  468. "type": "candle",
  469. "color": color,
  470. "padding": [15,15,0,15],
  471. "enableScroll": true,
  472. "enableMarkLine": true,
  473. "dataLabel": false,
  474. "xAxis": {
  475. "labelCount": 4,
  476. "itemCount": 40,
  477. "disableGrid": true,
  478. "gridColor": "#CCCCCC",
  479. "gridType": "solid",
  480. "dashLength": 4,
  481. "scrollShow": true,
  482. "scrollAlign": "left",
  483. "scrollColor": "#A6A6A6",
  484. "scrollBackgroundColor": "#EFEBEF"
  485. },
  486. "yAxis": {
  487. },
  488. "legend": {
  489. },
  490. "extra": {
  491. "candle": {
  492. "color": {
  493. "upLine": "#f04864",
  494. "upFill": "#f04864",
  495. "downLine": "#2fc25b",
  496. "downFill": "#2fc25b"
  497. },
  498. "average": {
  499. "show": true,
  500. "name": ["MA5","MA10","MA30"],
  501. "day": [5,10,20],
  502. "color": ["#1890ff","#2fc25b","#facc14"]
  503. }
  504. },
  505. "markLine": {
  506. "type": "dash",
  507. "dashLength": 5,
  508. "data": [
  509. {
  510. "value": 2150,
  511. "lineColor": "#f04864",
  512. "showLabel": true
  513. },
  514. {
  515. "value": 2350,
  516. "lineColor": "#f04864",
  517. "showLabel": true
  518. }
  519. ]
  520. }
  521. }
  522. },
  523. "mix":{
  524. "type": "mix",
  525. "color": color,
  526. "padding": [15,15,0,15],
  527. "xAxis": {
  528. "disableGrid": true,
  529. },
  530. "yAxis": {
  531. "disabled": false,
  532. "disableGrid": false,
  533. "splitNumber": 5,
  534. "gridType": "dash",
  535. "dashLength": 4,
  536. "gridColor": "#CCCCCC",
  537. "padding": 10,
  538. "showTitle": true,
  539. "data": []
  540. },
  541. "legend": {
  542. },
  543. "extra": {
  544. "mix": {
  545. "column": {
  546. "width": 20
  547. }
  548. },
  549. }
  550. },
  551. "scatter":{
  552. "type": "scatter",
  553. "color":color,
  554. "padding":[15,15,0,15],
  555. "dataLabel":false,
  556. "xAxis": {
  557. "disableGrid": false,
  558. "gridType":"dash",
  559. "splitNumber":5,
  560. "boundaryGap":"justify",
  561. "min":0
  562. },
  563. "yAxis": {
  564. "disableGrid": false,
  565. "gridType":"dash",
  566. },
  567. "legend": {
  568. },
  569. "extra": {
  570. "scatter": {
  571. },
  572. }
  573. },
  574. "bubble":{
  575. "type": "bubble",
  576. "color":color,
  577. "padding":[15,15,0,15],
  578. "xAxis": {
  579. "disableGrid": false,
  580. "gridType":"dash",
  581. "splitNumber":5,
  582. "boundaryGap":"justify",
  583. "min":0,
  584. "max":250
  585. },
  586. "yAxis": {
  587. "disableGrid": false,
  588. "gridType":"dash",
  589. "data":[{
  590. "min":0,
  591. "max":150
  592. }]
  593. },
  594. "legend": {
  595. },
  596. "extra": {
  597. "bubble": {
  598. "border":2,
  599. "opacity": 0.5,
  600. },
  601. }
  602. }
  603. }
  604. export default cfu;