config-ucharts.js 13 KB

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