config-ucharts.js 13 KB

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