config-ucharts.js 12 KB

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