config-ucharts.js 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619
  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. },
  284. }
  285. },
  286. "tline": {
  287. "type": "line",
  288. "color": color,
  289. "padding": [15, 10, 0, 15],
  290. "xAxis": {
  291. "disableGrid": false,
  292. "boundaryGap": "justify",
  293. },
  294. "yAxis": {
  295. "gridType": "dash",
  296. "dashLength": 2,
  297. "data": [{
  298. "min": 0,
  299. "max": 80
  300. }]
  301. },
  302. "legend": {},
  303. "extra": {
  304. "line": {
  305. "type": "curve",
  306. "width": 2
  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. },
  335. }
  336. },
  337. "column": {
  338. "type": "column",
  339. "color": color,
  340. "padding": [15, 15, 0, 5],
  341. "xAxis": {
  342. "disableGrid": true,
  343. },
  344. "yAxis": {
  345. "data": [{
  346. "min": 0
  347. }]
  348. },
  349. "legend": {},
  350. "extra": {
  351. "column": {
  352. "type": "group",
  353. "width": 30,
  354. "activeBgColor": "#000000",
  355. "activeBgOpacity": 0.08
  356. },
  357. }
  358. },
  359. "mount": {
  360. "type": "mount",
  361. "color": color,
  362. "padding": [15, 15, 0, 5],
  363. "xAxis": {
  364. "disableGrid": true,
  365. },
  366. "yAxis": {
  367. "data": [{
  368. "min": 0
  369. }]
  370. },
  371. "legend": {},
  372. "extra": {
  373. "mount": {
  374. "type": "mount",
  375. "widthRatio": 1.5,
  376. },
  377. }
  378. },
  379. "bar": {
  380. "type": "bar",
  381. "color": color,
  382. "padding": [15, 30, 0, 5],
  383. "xAxis": {
  384. "boundaryGap": "justify",
  385. "disableGrid": false,
  386. "min": 0,
  387. "axisLine": false
  388. },
  389. "yAxis": {},
  390. "legend": {},
  391. "extra": {
  392. "bar": {
  393. "type": "group",
  394. "width": 30,
  395. "meterBorde": 1,
  396. "meterFillColor": "#FFFFFF",
  397. "activeBgColor": "#000000",
  398. "activeBgOpacity": 0.08
  399. },
  400. }
  401. },
  402. "area": {
  403. "type": "area",
  404. "color": color,
  405. "padding": [15, 15, 0, 15],
  406. "xAxis": {
  407. "disableGrid": true,
  408. },
  409. "yAxis": {
  410. "gridType": "dash",
  411. "dashLength": 2,
  412. },
  413. "legend": {},
  414. "extra": {
  415. "area": {
  416. "type": "straight",
  417. "opacity": 0.2,
  418. "addLine": true,
  419. "width": 2,
  420. "gradient": false
  421. },
  422. }
  423. },
  424. "radar": {
  425. "type": "radar",
  426. "color": color,
  427. "padding": [5, 5, 5, 5],
  428. "dataLabel": false,
  429. "legend": {
  430. "show": true,
  431. "position": "right",
  432. "lineHeight": 25,
  433. },
  434. "extra": {
  435. "radar": {
  436. "gridType": "radar",
  437. "gridColor": "#CCCCCC",
  438. "gridCount": 3,
  439. "opacity": 0.2,
  440. "max": 200
  441. },
  442. }
  443. },
  444. "gauge": {
  445. "type": "gauge",
  446. "color": color,
  447. "title": {
  448. "name": "66Km/H",
  449. "fontSize": 25,
  450. "color": "#2fc25b",
  451. "offsetY": 50
  452. },
  453. "subtitle": {
  454. "name": "实时速度",
  455. "fontSize": 15,
  456. "color": "#1890ff",
  457. "offsetY": -50
  458. },
  459. "extra": {
  460. "gauge": {
  461. "type": "default",
  462. "width": 30,
  463. "labelColor": "#666666",
  464. "startAngle": 0.75,
  465. "endAngle": 0.25,
  466. "startNumber": 0,
  467. "endNumber": 100,
  468. "labelFormat": "",
  469. "splitLine": {
  470. "fixRadius": 0,
  471. "splitNumber": 10,
  472. "width": 30,
  473. "color": "#FFFFFF",
  474. "childNumber": 5,
  475. "childWidth": 12
  476. },
  477. "pointer": {
  478. "width": 24,
  479. "color": "auto"
  480. }
  481. }
  482. }
  483. },
  484. "candle": {
  485. "type": "candle",
  486. "color": color,
  487. "padding": [15, 15, 0, 15],
  488. "enableScroll": true,
  489. "enableMarkLine": true,
  490. "dataLabel": false,
  491. "xAxis": {
  492. "labelCount": 4,
  493. "itemCount": 40,
  494. "disableGrid": true,
  495. "gridColor": "#CCCCCC",
  496. "gridType": "solid",
  497. "dashLength": 4,
  498. "scrollShow": true,
  499. "scrollAlign": "left",
  500. "scrollColor": "#A6A6A6",
  501. "scrollBackgroundColor": "#EFEBEF"
  502. },
  503. "yAxis": {},
  504. "legend": {},
  505. "extra": {
  506. "candle": {
  507. "color": {
  508. "upLine": "#f04864",
  509. "upFill": "#f04864",
  510. "downLine": "#2fc25b",
  511. "downFill": "#2fc25b"
  512. },
  513. "average": {
  514. "show": true,
  515. "name": ["MA5", "MA10", "MA30"],
  516. "day": [5, 10, 20],
  517. "color": ["#1890ff", "#2fc25b", "#facc14"]
  518. }
  519. },
  520. "markLine": {
  521. "type": "dash",
  522. "dashLength": 5,
  523. "data": [{
  524. "value": 2150,
  525. "lineColor": "#f04864",
  526. "showLabel": true
  527. },
  528. {
  529. "value": 2350,
  530. "lineColor": "#f04864",
  531. "showLabel": true
  532. }
  533. ]
  534. }
  535. }
  536. },
  537. "mix": {
  538. "type": "mix",
  539. "color": color,
  540. "padding": [15, 15, 0, 15],
  541. "xAxis": {
  542. "disableGrid": true,
  543. },
  544. "yAxis": {
  545. "disabled": false,
  546. "disableGrid": false,
  547. "splitNumber": 5,
  548. "gridType": "dash",
  549. "dashLength": 4,
  550. "gridColor": "#CCCCCC",
  551. "padding": 10,
  552. "showTitle": true,
  553. "data": []
  554. },
  555. "legend": {},
  556. "extra": {
  557. "mix": {
  558. "column": {
  559. "width": 20
  560. }
  561. },
  562. }
  563. },
  564. "scatter": {
  565. "type": "scatter",
  566. "color": color,
  567. "padding": [15, 15, 0, 15],
  568. "dataLabel": false,
  569. "xAxis": {
  570. "disableGrid": false,
  571. "gridType": "dash",
  572. "splitNumber": 5,
  573. "boundaryGap": "justify",
  574. "min": 0
  575. },
  576. "yAxis": {
  577. "disableGrid": false,
  578. "gridType": "dash",
  579. },
  580. "legend": {},
  581. "extra": {
  582. "scatter": {},
  583. }
  584. },
  585. "bubble": {
  586. "type": "bubble",
  587. "color": color,
  588. "padding": [15, 15, 0, 15],
  589. "xAxis": {
  590. "disableGrid": false,
  591. "gridType": "dash",
  592. "splitNumber": 5,
  593. "boundaryGap": "justify",
  594. "min": 0,
  595. "max": 250
  596. },
  597. "yAxis": {
  598. "disableGrid": false,
  599. "gridType": "dash",
  600. "data": [{
  601. "min": 0,
  602. "max": 150
  603. }]
  604. },
  605. "legend": {},
  606. "extra": {
  607. "bubble": {
  608. "border": 2,
  609. "opacity": 0.5,
  610. },
  611. }
  612. }
  613. }
  614. export default cfu;