config-ucharts.js 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588
  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. "yAxisDemo1":function(val){return val+'元'},
  55. "yAxisDemo2":function(val){return val.toFixed(2)},
  56. "xAxisDemo1":function(val){return val+'年'},
  57. "xAxisDemo2":function(val){return formatDateTime(val,'h:m')},
  58. "seriesDemo1":function(val){return val+'元'},
  59. "tooltipDemo1":function(item, category, index, opts){
  60. if(index==0){
  61. return '随便用'+item.data+'年'
  62. }else{
  63. return '其他我没改'+item.data+'天'
  64. }
  65. },
  66. "pieDemo":function(val, index, series){
  67. if(index !== undefined){
  68. return series[index].name+':'+series[index].data+'元'
  69. }
  70. },
  71. // column_1
  72. "column_1": function(item, category, index, opts) {
  73. return item.name
  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. },
  351. "legend": {
  352. },
  353. "extra": {
  354. "bar": {
  355. "type": "group",
  356. "width": 30,
  357. "meterBorde": 1,
  358. "meterFillColor": "#FFFFFF",
  359. "activeBgColor": "#000000",
  360. "activeBgOpacity": 0.08
  361. },
  362. }
  363. },
  364. "area":{
  365. "type": "area",
  366. "color": color,
  367. "padding": [15,15,0,15],
  368. "xAxis": {
  369. "disableGrid": true,
  370. },
  371. "yAxis": {
  372. "gridType": "dash",
  373. "dashLength": 2,
  374. },
  375. "legend": {
  376. },
  377. "extra": {
  378. "area": {
  379. "type": "straight",
  380. "opacity": 0.2,
  381. "addLine": true,
  382. "width": 2,
  383. "gradient": false
  384. },
  385. }
  386. },
  387. "radar":{
  388. "type": "radar",
  389. "color": color,
  390. "padding": [5,5,5,5],
  391. "dataLabel": false,
  392. "legend": {
  393. "show": true,
  394. "position": "right",
  395. "lineHeight": 25,
  396. },
  397. "extra": {
  398. "radar": {
  399. "gridType": "radar",
  400. "gridColor": "#CCCCCC",
  401. "gridCount": 3,
  402. "opacity": 0.2,
  403. "max": 200
  404. },
  405. }
  406. },
  407. "gauge":{
  408. "type": "gauge",
  409. "color": color,
  410. "title": {
  411. "name": "66Km/H",
  412. "fontSize": 25,
  413. "color": "#2fc25b",
  414. "offsetY": 50
  415. },
  416. "subtitle": {
  417. "name": "实时速度",
  418. "fontSize": 15,
  419. "color": "#1890ff",
  420. "offsetY": -50
  421. },
  422. "extra": {
  423. "gauge": {
  424. "type": "default",
  425. "width": 30,
  426. "labelColor": "#666666",
  427. "startAngle": 0.75,
  428. "endAngle": 0.25,
  429. "startNumber": 0,
  430. "endNumber": 100,
  431. "labelFormat": "",
  432. "splitLine": {
  433. "fixRadius": 0,
  434. "splitNumber": 10,
  435. "width": 30,
  436. "color": "#FFFFFF",
  437. "childNumber": 5,
  438. "childWidth": 12
  439. },
  440. "pointer": {
  441. "width": 24,
  442. "color": "auto"
  443. }
  444. }
  445. }
  446. },
  447. "candle":{
  448. "type": "candle",
  449. "color": color,
  450. "padding": [15,15,0,15],
  451. "enableScroll": true,
  452. "enableMarkLine": true,
  453. "dataLabel": false,
  454. "xAxis": {
  455. "labelCount": 4,
  456. "itemCount": 40,
  457. "disableGrid": true,
  458. "gridColor": "#CCCCCC",
  459. "gridType": "solid",
  460. "dashLength": 4,
  461. "scrollShow": true,
  462. "scrollAlign": "left",
  463. "scrollColor": "#A6A6A6",
  464. "scrollBackgroundColor": "#EFEBEF"
  465. },
  466. "yAxis": {
  467. },
  468. "legend": {
  469. },
  470. "extra": {
  471. "candle": {
  472. "color": {
  473. "upLine": "#f04864",
  474. "upFill": "#f04864",
  475. "downLine": "#2fc25b",
  476. "downFill": "#2fc25b"
  477. },
  478. "average": {
  479. "show": true,
  480. "name": ["MA5","MA10","MA30"],
  481. "day": [5,10,20],
  482. "color": ["#1890ff","#2fc25b","#facc14"]
  483. }
  484. },
  485. "markLine": {
  486. "type": "dash",
  487. "dashLength": 5,
  488. "data": [
  489. {
  490. "value": 2150,
  491. "lineColor": "#f04864",
  492. "showLabel": true
  493. },
  494. {
  495. "value": 2350,
  496. "lineColor": "#f04864",
  497. "showLabel": true
  498. }
  499. ]
  500. }
  501. }
  502. },
  503. "mix":{
  504. "type": "mix",
  505. "color": color,
  506. "padding": [15,15,0,15],
  507. "xAxis": {
  508. "disableGrid": true,
  509. },
  510. "yAxis": {
  511. "disabled": false,
  512. "disableGrid": false,
  513. "splitNumber": 5,
  514. "gridType": "dash",
  515. "dashLength": 4,
  516. "gridColor": "#CCCCCC",
  517. "padding": 10,
  518. "showTitle": true,
  519. "data": []
  520. },
  521. "legend": {
  522. },
  523. "extra": {
  524. "mix": {
  525. "column": {
  526. "width": 20
  527. }
  528. },
  529. }
  530. },
  531. "scatter":{
  532. "type": "scatter",
  533. "color":color,
  534. "padding":[15,15,0,15],
  535. "dataLabel":false,
  536. "xAxis": {
  537. "disableGrid": false,
  538. "gridType":"dash",
  539. "splitNumber":5,
  540. "boundaryGap":"justify",
  541. "min":0
  542. },
  543. "yAxis": {
  544. "disableGrid": false,
  545. "gridType":"dash",
  546. },
  547. "legend": {
  548. },
  549. "extra": {
  550. "scatter": {
  551. },
  552. }
  553. },
  554. "bubble":{
  555. "type": "bubble",
  556. "color":color,
  557. "padding":[15,15,0,15],
  558. "xAxis": {
  559. "disableGrid": false,
  560. "gridType":"dash",
  561. "splitNumber":5,
  562. "boundaryGap":"justify",
  563. "min":0,
  564. "max":250
  565. },
  566. "yAxis": {
  567. "disableGrid": false,
  568. "gridType":"dash",
  569. "data":[{
  570. "min":0,
  571. "max":150
  572. }]
  573. },
  574. "legend": {
  575. },
  576. "extra": {
  577. "bubble": {
  578. "border":2,
  579. "opacity": 0.5,
  580. },
  581. }
  582. }
  583. }
  584. export default cfu;