config-ucharts.js 13 KB

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