config-ucharts.js 12 KB

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