config-ucharts.js 13 KB

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