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