config-ucharts.js 12 KB

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