config-ucharts.js 12 KB

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