config-ucharts.js 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709
  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') {
  36. return y + '-' + m + '-' + d + ' ' + h + ':' + minute + ':' + second;
  37. }
  38. if (returnType == 'y-m-d') {
  39. return y + '-' + m + '-' + d;
  40. }
  41. if (returnType == 'h:m') {
  42. return h + ':' + minute;
  43. }
  44. if (returnType == 'h:m:s') {
  45. return h + ':' + minute + ':' + second;
  46. }
  47. return [y, m, d, h, minute, second];
  48. }
  49. module.exports = {
  50. //demotype为自定义图表类型,一般不需要自定义图表类型,只需要改根节点上对应的类型即可
  51. "type": ["pie", "ring", "rose", "word", "funnel", "map", "arcbar", "line", "column", "bar", "area", "radar",
  52. "gauge", "candle", "mix", "tline", "tarea", "scatter", "bubble", "demotype"
  53. ],
  54. "range": ["饼状图", "圆环图", "玫瑰图", "词云图", "漏斗图", "地图", "圆弧进度条", "折线图", "柱状图", "条状图", "区域图", "雷达图", "仪表盘", "K线图",
  55. "混合图", "时间轴折线", "时间轴区域", "散点图", "气泡图", "自定义类型"
  56. ],
  57. //增加自定义图表类型,如果需要categories,请在这里加入您的图表类型,例如最后的"demotype"
  58. //自定义类型时需要注意"tline","tarea","scatter","bubble"等时间轴(矢量x轴)类图表,没有categories,不需要加入categories
  59. "categories": ["line", "column", "bar", "area", "radar", "gauge", "candle", "mix", "demotype"],
  60. //instance为实例变量承载属性,不要删除
  61. "instance": {},
  62. //option为opts及eopts承载属性,不要删除
  63. "option": {},
  64. //下面是自定义format配置,因除H5端外的其他端无法通过props传递函数,只能通过此属性对应下标的方式来替换
  65. "formatter": {
  66. "yAxisDemo1": function(val) {
  67. return val + '元'
  68. },
  69. "yAxisDemo2": function(val) {
  70. return val.toFixed(2)
  71. },
  72. "xAxisDemo1": function(val) {
  73. return val + '年'
  74. },
  75. "xAxisDemo2": function(val) {
  76. return formatDateTime(val, 'h:m')
  77. },
  78. "seriesDemo1": function(val) {
  79. return val + '元'
  80. },
  81. "tooltipDemo1": function(item, category, index, opts) {
  82. if (index == 0) {
  83. return '随便用' + item.data + '年'
  84. } else {
  85. return '其他我没改' + item.data + '天'
  86. }
  87. },
  88. "pieDemo": function(val, index, series) {
  89. if (index !== undefined) {
  90. return series[index].name + ':' + series[index].data + '元'
  91. }
  92. },
  93. },
  94. //这里演示了自定义您的图表类型的option,可以随意命名,之后在组件上 type="demotype" 后,组件会调用这个花括号里的option,如果组件上还存在opts参数,会将demotype与opts中option合并后渲染图表。
  95. "demotype": {
  96. //我这里把曲线图当做了自定义图表类型,您可以根据需要随意指定类型或配置
  97. "type": "line",
  98. "color": color,
  99. "padding": [15, 10, 0, 15],
  100. "xAxis": {
  101. "disableGrid": true,
  102. },
  103. "yAxis": {
  104. "gridType": "dash",
  105. "dashLength": 2,
  106. },
  107. "legend": {},
  108. "extra": {
  109. "line": {
  110. "type": "curve",
  111. "width": 2
  112. },
  113. }
  114. },
  115. //下面是自定义配置,请添加项目所需的通用配置
  116. "pie": {
  117. "type": "pie",
  118. "color": color,
  119. "padding": [5, 5, 5, 5],
  120. "extra": {
  121. "pie": {
  122. "activeOpacity": 0.5,
  123. "activeRadius": 10,
  124. "offsetAngle": 0,
  125. "labelWidth": 15,
  126. "border": true,
  127. "borderWidth": 3,
  128. "borderColor": "#FFFFFF"
  129. },
  130. }
  131. },
  132. "ring": {
  133. "type": "ring",
  134. "color": color,
  135. "padding": [5, 5, 5, 5],
  136. "rotate": false,
  137. "dataLabel": true,
  138. "legend": {
  139. "show": true,
  140. "position": "right",
  141. "lineHeight": 25,
  142. },
  143. "title": {
  144. "name": "收益率",
  145. "fontSize": 15,
  146. "color": "#666666"
  147. },
  148. "subtitle": {
  149. "name": "70%",
  150. "fontSize": 25,
  151. "color": "#7cb5ec"
  152. },
  153. "extra": {
  154. "ring": {
  155. "ringWidth": 30,
  156. "activeOpacity": 0.5,
  157. "activeRadius": 10,
  158. "offsetAngle": 0,
  159. "labelWidth": 15,
  160. "border": true,
  161. "borderWidth": 3,
  162. "borderColor": "#FFFFFF"
  163. },
  164. },
  165. },
  166. "rose": {
  167. "type": "rose",
  168. "color": color,
  169. "padding": [5, 5, 5, 5],
  170. "legend": {
  171. "show": true,
  172. "position": "left",
  173. "lineHeight": 25,
  174. },
  175. "extra": {
  176. "rose": {
  177. "type": "area",
  178. "minRadius": 50,
  179. "activeOpacity": 0.5,
  180. "activeRadius": 10,
  181. "offsetAngle": 0,
  182. "labelWidth": 15,
  183. "border": false,
  184. "borderWidth": 2,
  185. "borderColor": "#FFFFFF"
  186. },
  187. }
  188. },
  189. "word": {
  190. "type": "word",
  191. "color": color,
  192. "extra": {
  193. "word": {
  194. "type": "normal",
  195. "autoColors": false
  196. }
  197. }
  198. },
  199. "funnel": {
  200. "type": "funnel",
  201. "color": color,
  202. "padding": [15, 15, 0, 15],
  203. "extra": {
  204. "funnel": {
  205. "activeOpacity": 0.3,
  206. "activeWidth": 10,
  207. "border": true,
  208. "borderWidth": 2,
  209. "borderColor": "#FFFFFF",
  210. "fillOpacity": 1,
  211. "labelAlign": "right"
  212. },
  213. }
  214. },
  215. "map": {
  216. "type": "map",
  217. "color": color,
  218. "padding": [0, 0, 0, 0],
  219. "dataLabel": true,
  220. "extra": {
  221. "map": {
  222. "border": true,
  223. "borderWidth": 1,
  224. "borderColor": "#666666",
  225. "fillOpacity": 0.6,
  226. "activeBorderColor": "#F04864",
  227. "activeFillColor": "#FACC14",
  228. "activeFillOpacity": 1
  229. },
  230. }
  231. },
  232. "arcbar": {
  233. "type": "arcbar",
  234. "color": color,
  235. "title": {
  236. "name": "百分比",
  237. "fontSize": 25,
  238. "color": "#00FF00"
  239. },
  240. "subtitle": {
  241. "name": "默认标题",
  242. "fontSize": 15,
  243. "color": "#666666"
  244. },
  245. "extra": {
  246. "arcbar": {
  247. "type": "default",
  248. "width": 12,
  249. "backgroundColor": "#E9E9E9",
  250. "startAngle": 0.75,
  251. "endAngle": 0.25,
  252. "gap": 2
  253. }
  254. }
  255. },
  256. "line": {
  257. "type": "line",
  258. "color": color,
  259. "padding": [15, 10, 0, 15],
  260. "xAxis": {
  261. "disableGrid": true,
  262. },
  263. "yAxis": {
  264. "gridType": "dash",
  265. "dashLength": 2,
  266. },
  267. "legend": {},
  268. "extra": {
  269. "line": {
  270. "type": "straight",
  271. "width": 2
  272. },
  273. }
  274. },
  275. "tline": {
  276. "type": "line",
  277. "color": color,
  278. "padding": [15, 10, 0, 15],
  279. "xAxis": {
  280. "disableGrid": false,
  281. "boundaryGap": "justify",
  282. },
  283. "yAxis": {
  284. "gridType": "dash",
  285. "dashLength": 2,
  286. "data": [{
  287. "min": 0,
  288. "max": 80
  289. }]
  290. },
  291. "legend": {},
  292. "extra": {
  293. "line": {
  294. "type": "curve",
  295. "width": 2
  296. },
  297. }
  298. },
  299. "tarea": {
  300. "type": "area",
  301. "color": color,
  302. "padding": [15, 10, 0, 15],
  303. "xAxis": {
  304. "disableGrid": true,
  305. "boundaryGap": "justify",
  306. },
  307. "yAxis": {
  308. "gridType": "dash",
  309. "dashLength": 2,
  310. "data": [{
  311. "min": 0,
  312. "max": 80
  313. }]
  314. },
  315. "legend": {},
  316. "extra": {
  317. "area": {
  318. "type": "curve",
  319. "opacity": 0.2,
  320. "addLine": true,
  321. "width": 2,
  322. "gradient": true
  323. },
  324. }
  325. },
  326. // "column":{
  327. // "type": "column",
  328. // "canvasId": "",
  329. // "canvas2d": false,
  330. // "background": "none",
  331. // "animation": true,
  332. // "timing": "easeOut",
  333. // "duration": 1000,
  334. // "padding": [
  335. // 15,
  336. // 15,
  337. // 0,
  338. // 5
  339. // ],
  340. // "rotate": false,
  341. // "errorReload": true,
  342. // "fontSize": 13,
  343. // "fontColor": "#666666",
  344. // "enableScroll": false,
  345. // "touchMoveLimit": 60,
  346. // "enableMarkLine": false,
  347. // "dataLabel": true,
  348. // "dataPointShape": true,
  349. // "dataPointShapeType": "solid",
  350. // "tapLegend": true,
  351. // "xAxis": {
  352. // "disabled": false,
  353. // "axisLine": true,
  354. // "axisLineColor": "#CCCCCC",
  355. // "calibration": false,
  356. // "fontColor": "#666666",
  357. // "fontSize": 13,
  358. // "rotateLabel": false,
  359. // "itemCount": 5,
  360. // "boundaryGap": "center",
  361. // "disableGrid": true,
  362. // "gridColor": "#CCCCCC",
  363. // "gridType": "solid",
  364. // "dashLength": 4,
  365. // "gridEval": 1,
  366. // "scrollShow": false,
  367. // "scrollAlign": "left",
  368. // "scrollColor": "#A6A6A6",
  369. // "scrollBackgroundColor": "#EFEBEF",
  370. // "min": 0,
  371. // "format": ""
  372. // },
  373. // "yAxis": {
  374. // "disabled": true,
  375. // "disableGrid": true,
  376. // "splitNumber": 5,
  377. // "gridType": "solid",
  378. // "dashLength": 8,
  379. // "gridColor": "#CCCCCC",
  380. // "padding": 10,
  381. // "showTitle": false,
  382. // "data": []
  383. // },
  384. // "legend": {
  385. // "show": false,
  386. // "position": "bottom",
  387. // "float": "center",
  388. // "padding": 5,
  389. // "margin": 5,
  390. // "backgroundColor": "rgba(0,0,0,0)",
  391. // "borderColor": "rgba(0,0,0,0)",
  392. // "borderWidth": 0,
  393. // "fontSize": 13,
  394. // "fontColor": "#666666",
  395. // "lineHeight": 11,
  396. // "hiddenColor": "#CECECE",
  397. // "itemGap": 10
  398. // },
  399. // "extra": {
  400. // "column": {
  401. // "type": "group",
  402. // "width": 30,
  403. // "seriesGap": 2,
  404. // "categoryGap": 3,
  405. // "barBorderCircle": false,
  406. // "linearType": "none",
  407. // "linearOpacity": 1,
  408. // "colorStop": 0,
  409. // "meterBorder": 1,
  410. // "meterFillColor": "#FFFFFF",
  411. // "activeBgColor": "#000000",
  412. // "activeBgOpacity": 0.08,
  413. // "meterBorde": 1
  414. // },
  415. // "tooltip": {
  416. // "showBox": true,
  417. // "showArrow": true,
  418. // "showCategory": false,
  419. // "borderWidth": 0,
  420. // "borderRadius": 0,
  421. // "borderColor": "#000000",
  422. // "borderOpacity": 0.7,
  423. // "bgColor": "#000000",
  424. // "bgOpacity": 0.7,
  425. // "gridType": "solid",
  426. // "dashLength": 4,
  427. // "gridColor": "#CCCCCC",
  428. // "fontColor": "#FFFFFF",
  429. // "splitLine": true,
  430. // "horizentalLine": false,
  431. // "xAxisLabel": false,
  432. // "yAxisLabel": false,
  433. // "labelBgColor": "#FFFFFF",
  434. // "labelBgOpacity": 0.7,
  435. // "labelFontColor": "#666666"
  436. // },
  437. // "markLine": {
  438. // "type": "solid",
  439. // "dashLength": 4,
  440. // "data": []
  441. // }
  442. // }
  443. // },
  444. "column": {
  445. "type": "column",
  446. "color": color,
  447. "padding": [15, 15, 0, 5],
  448. "xAxis": {
  449. "disableGrid": true,
  450. },
  451. "yAxis": {
  452. disabled:true,
  453. "disableGrid": true,
  454. "data": [{
  455. "min": 0
  456. }]
  457. },
  458. "legend": {},
  459. "extra": {
  460. "column": {
  461. "type": "group",
  462. "width": 30,
  463. "meterBorde": 1,
  464. "meterFillColor": "#FFFFFF",
  465. "activeBgColor": "#000000",
  466. "activeBgOpacity": 0.08
  467. },
  468. }
  469. },
  470. "bar": {
  471. "type": "bar",
  472. "color": color,
  473. "padding": [15, 30, 0, 5],
  474. "xAxis": {
  475. "boundaryGap": "justify",
  476. "disableGrid": false,
  477. "min": 0,
  478. "axisLine": false
  479. },
  480. "yAxis": {},
  481. "legend": {},
  482. "extra": {
  483. "bar": {
  484. "type": "group",
  485. "width": 30,
  486. "meterBorde": 1,
  487. "meterFillColor": "#FFFFFF",
  488. "activeBgColor": "#000000",
  489. "activeBgOpacity": 0.08
  490. },
  491. }
  492. },
  493. "area": {
  494. "type": "area",
  495. "color": color,
  496. "padding": [15, 15, 0, 15],
  497. "xAxis": {
  498. "disableGrid": true,
  499. },
  500. "yAxis": {
  501. "gridType": "dash",
  502. "dashLength": 2,
  503. },
  504. "legend": {},
  505. "extra": {
  506. "area": {
  507. "type": "straight",
  508. "opacity": 0.2,
  509. "addLine": true,
  510. "width": 2,
  511. "gradient": false
  512. },
  513. }
  514. },
  515. "radar": {
  516. "type": "radar",
  517. "color": color,
  518. "padding": [5, 5, 5, 5],
  519. "dataLabel": false,
  520. "legend": {
  521. "show": true,
  522. "position": "right",
  523. "lineHeight": 25,
  524. },
  525. "extra": {
  526. "radar": {
  527. "gridType": "radar",
  528. "gridColor": "#CCCCCC",
  529. "gridCount": 3,
  530. "opacity": 0.2,
  531. "max": 200
  532. },
  533. }
  534. },
  535. "gauge": {
  536. "type": "gauge",
  537. "color": color,
  538. "title": {
  539. "name": "66Km/H",
  540. "fontSize": 25,
  541. "color": "#2fc25b",
  542. "offsetY": 50
  543. },
  544. "subtitle": {
  545. "name": "实时速度",
  546. "fontSize": 15,
  547. "color": "#1890ff",
  548. "offsetY": -50
  549. },
  550. "extra": {
  551. "gauge": {
  552. "type": "default",
  553. "width": 30,
  554. "labelColor": "#666666",
  555. "startAngle": 0.75,
  556. "endAngle": 0.25,
  557. "startNumber": 0,
  558. "endNumber": 100,
  559. "labelFormat": "",
  560. "splitLine": {
  561. "fixRadius": 0,
  562. "splitNumber": 10,
  563. "width": 30,
  564. "color": "#FFFFFF",
  565. "childNumber": 5,
  566. "childWidth": 12
  567. },
  568. "pointer": {
  569. "width": 24,
  570. "color": "auto"
  571. }
  572. }
  573. }
  574. },
  575. "candle": {
  576. "type": "candle",
  577. "color": color,
  578. "padding": [15, 15, 0, 15],
  579. "enableScroll": true,
  580. "enableMarkLine": true,
  581. "dataLabel": false,
  582. "xAxis": {
  583. "labelCount": 4,
  584. "itemCount": 40,
  585. "disableGrid": true,
  586. "gridColor": "#CCCCCC",
  587. "gridType": "solid",
  588. "dashLength": 4,
  589. "scrollShow": true,
  590. "scrollAlign": "left",
  591. "scrollColor": "#A6A6A6",
  592. "scrollBackgroundColor": "#EFEBEF"
  593. },
  594. "yAxis": {},
  595. "legend": {},
  596. "extra": {
  597. "candle": {
  598. "color": {
  599. "upLine": "#f04864",
  600. "upFill": "#f04864",
  601. "downLine": "#2fc25b",
  602. "downFill": "#2fc25b"
  603. },
  604. "average": {
  605. "show": true,
  606. "name": ["MA5", "MA10", "MA30"],
  607. "day": [5, 10, 20],
  608. "color": ["#1890ff", "#2fc25b", "#facc14"]
  609. }
  610. },
  611. "markLine": {
  612. "type": "dash",
  613. "dashLength": 5,
  614. "data": [{
  615. "value": 2150,
  616. "lineColor": "#f04864",
  617. "showLabel": true
  618. },
  619. {
  620. "value": 2350,
  621. "lineColor": "#f04864",
  622. "showLabel": true
  623. }
  624. ]
  625. }
  626. }
  627. },
  628. "mix": {
  629. "type": "mix",
  630. "color": color,
  631. "padding": [15, 15, 0, 15],
  632. "xAxis": {
  633. "disableGrid": true,
  634. },
  635. "yAxis": {
  636. "disabled": false,
  637. "disableGrid": false,
  638. "splitNumber": 5,
  639. "gridType": "dash",
  640. "dashLength": 4,
  641. "gridColor": "#CCCCCC",
  642. "padding": 10,
  643. "showTitle": true,
  644. "data": []
  645. },
  646. "legend": {},
  647. "extra": {
  648. "mix": {
  649. "column": {
  650. "width": 20
  651. }
  652. },
  653. }
  654. },
  655. "scatter": {
  656. "type": "scatter",
  657. "color": color,
  658. "padding": [15, 15, 0, 15],
  659. "dataLabel": false,
  660. "xAxis": {
  661. "disableGrid": false,
  662. "gridType": "dash",
  663. "splitNumber": 5,
  664. "boundaryGap": "justify",
  665. "min": 0
  666. },
  667. "yAxis": {
  668. "disableGrid": false,
  669. "gridType": "dash",
  670. },
  671. "legend": {},
  672. "extra": {
  673. "scatter": {},
  674. }
  675. },
  676. "bubble": {
  677. "type": "bubble",
  678. "color": color,
  679. "padding": [15, 15, 0, 15],
  680. "xAxis": {
  681. "disableGrid": false,
  682. "gridType": "dash",
  683. "splitNumber": 5,
  684. "boundaryGap": "justify",
  685. "min": 0,
  686. "max": 250
  687. },
  688. "yAxis": {
  689. "disableGrid": false,
  690. "gridType": "dash",
  691. "data": [{
  692. "min": 0,
  693. "max": 150
  694. }]
  695. },
  696. "legend": {},
  697. "extra": {
  698. "bubble": {
  699. "border": 2,
  700. "opacity": 0.5,
  701. },
  702. }
  703. }
  704. }