config-ucharts.js 13 KB

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