config-ucharts.js 13 KB

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