config-ucharts.js 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679
  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 = [
  20. "#1890FF",
  21. "#91CB74",
  22. "#FAC858",
  23. "#EE6666",
  24. "#73C0DE",
  25. "#3CA272",
  26. "#FC8452",
  27. "#9A60B4",
  28. "#ea7ccc",
  29. ];
  30. //事件转换函数,主要用作格式化x轴为时间轴,根据需求自行修改
  31. const formatDateTime = (timeStamp, returnType) => {
  32. var date = new Date();
  33. date.setTime(timeStamp * 1000);
  34. var y = date.getFullYear();
  35. var m = date.getMonth() + 1;
  36. m = m < 10 ? "0" + m : m;
  37. var d = date.getDate();
  38. d = d < 10 ? "0" + d : d;
  39. var h = date.getHours();
  40. h = h < 10 ? "0" + h : h;
  41. var minute = date.getMinutes();
  42. var second = date.getSeconds();
  43. minute = minute < 10 ? "0" + minute : minute;
  44. second = second < 10 ? "0" + second : second;
  45. if (returnType == "full") {
  46. return y + "-" + m + "-" + d + " " + h + ":" + minute + ":" + second;
  47. }
  48. if (returnType == "y-m-d") {
  49. return y + "-" + m + "-" + d;
  50. }
  51. if (returnType == "h:m") {
  52. return h + ":" + minute;
  53. }
  54. if (returnType == "h:m:s") {
  55. return h + ":" + minute + ":" + second;
  56. }
  57. return [y, m, d, h, minute, second];
  58. };
  59. const cfu = {
  60. //demotype为自定义图表类型,一般不需要自定义图表类型,只需要改根节点上对应的类型即可
  61. type: [
  62. "pie",
  63. "ring",
  64. "rose",
  65. "word",
  66. "funnel",
  67. "map",
  68. "arcbar",
  69. "line",
  70. "column",
  71. "mount",
  72. "bar",
  73. "area",
  74. "radar",
  75. "gauge",
  76. "candle",
  77. "mix",
  78. "tline",
  79. "tarea",
  80. "scatter",
  81. "bubble",
  82. "demotype",
  83. ],
  84. range: [
  85. "饼状图",
  86. "圆环图",
  87. "玫瑰图",
  88. "词云图",
  89. "漏斗图",
  90. "地图",
  91. "圆弧进度条",
  92. "折线图",
  93. "柱状图",
  94. "山峰图",
  95. "条状图",
  96. "区域图",
  97. "雷达图",
  98. "仪表盘",
  99. "K线图",
  100. "混合图",
  101. "时间轴折线",
  102. "时间轴区域",
  103. "散点图",
  104. "气泡图",
  105. "自定义类型",
  106. ],
  107. //增加自定义图表类型,如果需要categories,请在这里加入您的图表类型,例如最后的"demotype"
  108. //自定义类型时需要注意"tline","tarea","scatter","bubble"等时间轴(矢量x轴)类图表,没有categories,不需要加入categories
  109. categories: [
  110. "line",
  111. "column",
  112. "mount",
  113. "bar",
  114. "area",
  115. "radar",
  116. "gauge",
  117. "candle",
  118. "mix",
  119. "demotype",
  120. ],
  121. //instance为实例变量承载属性,不要删除
  122. instance: {},
  123. //option为opts及eopts承载属性,不要删除
  124. option: {},
  125. //下面是自定义format配置,因除H5端外的其他端无法通过props传递函数,只能通过此属性对应下标的方式来替换
  126. formatter: {
  127. yAxisDemo1: function (val, index, opts) {
  128. return val + "元";
  129. },
  130. yAxisDemo2: function (val, index, opts) {
  131. return val.toFixed(2);
  132. },
  133. xAxisDemo1: function (val, index, opts) {
  134. return val + "年";
  135. },
  136. xAxisDemo2: function (val, index, opts) {
  137. return formatDateTime(val, "h:m");
  138. },
  139. xAxisDemo3: function (val, index, opts) {
  140. return formatDateTime(val, "h:m:s");
  141. },
  142. seriesDemo1: function (val, index, series, opts) {
  143. return val + "元";
  144. },
  145. tooltipDemo1: function (item, category, index, opts) {
  146. if (index == 0) {
  147. return "随便用" + item.data + "年";
  148. } else {
  149. return "其他我没改" + item.data + "天";
  150. }
  151. },
  152. pieDemo: function (val, index, series, opts) {
  153. if (index !== undefined) {
  154. return series[index].name + ":" + series[index].data + "元";
  155. }
  156. },
  157. },
  158. //这里演示了自定义您的图表类型的option,可以随意命名,之后在组件上 type="demotype" 后,组件会调用这个花括号里的option,如果组件上还存在opts参数,会将demotype与opts中option合并后渲染图表。
  159. demotype: {
  160. //我这里把曲线图当做了自定义图表类型,您可以根据需要随意指定类型或配置
  161. type: "line",
  162. color: color,
  163. padding: [15, 10, 0, 15],
  164. xAxis: {
  165. disableGrid: true,
  166. },
  167. yAxis: {
  168. gridType: "dash",
  169. dashLength: 2,
  170. },
  171. legend: {},
  172. extra: {
  173. line: {
  174. type: "curve",
  175. width: 2,
  176. },
  177. },
  178. },
  179. //下面是自定义配置,请添加项目所需的通用配置
  180. pie: {
  181. type: "pie",
  182. color: color,
  183. padding: [5, 5, 5, 5],
  184. extra: {
  185. pie: {
  186. activeOpacity: 0.5,
  187. activeRadius: 10,
  188. offsetAngle: 0,
  189. labelWidth: 15,
  190. border: true,
  191. borderWidth: 3,
  192. borderColor: "#FFFFFF",
  193. },
  194. },
  195. },
  196. ring: {
  197. type: "ring",
  198. color: color,
  199. padding: [5, 5, 5, 5],
  200. rotate: false,
  201. dataLabel: true,
  202. legend: {
  203. show: true,
  204. position: "right",
  205. lineHeight: 25,
  206. },
  207. title: {
  208. name: "收益率",
  209. fontSize: 15,
  210. color: "#666666",
  211. },
  212. subtitle: {
  213. name: "70%",
  214. fontSize: 25,
  215. color: "#7cb5ec",
  216. },
  217. extra: {
  218. ring: {
  219. ringWidth: 30,
  220. activeOpacity: 0.5,
  221. activeRadius: 10,
  222. offsetAngle: 0,
  223. labelWidth: 15,
  224. border: true,
  225. borderWidth: 3,
  226. borderColor: "#FFFFFF",
  227. },
  228. },
  229. },
  230. rose: {
  231. type: "rose",
  232. color: color,
  233. padding: [5, 5, 5, 5],
  234. legend: {
  235. show: true,
  236. position: "left",
  237. lineHeight: 25,
  238. },
  239. extra: {
  240. rose: {
  241. type: "area",
  242. minRadius: 50,
  243. activeOpacity: 0.5,
  244. activeRadius: 10,
  245. offsetAngle: 0,
  246. labelWidth: 15,
  247. border: false,
  248. borderWidth: 2,
  249. borderColor: "#FFFFFF",
  250. },
  251. },
  252. },
  253. word: {
  254. type: "word",
  255. color: color,
  256. extra: {
  257. word: {
  258. type: "normal",
  259. autoColors: false,
  260. },
  261. },
  262. },
  263. funnel: {
  264. type: "funnel",
  265. color: color,
  266. padding: [15, 15, 0, 15],
  267. extra: {
  268. funnel: {
  269. activeOpacity: 0.3,
  270. activeWidth: 10,
  271. border: true,
  272. borderWidth: 2,
  273. borderColor: "#FFFFFF",
  274. fillOpacity: 1,
  275. labelAlign: "right",
  276. },
  277. },
  278. },
  279. map: {
  280. type: "map",
  281. color: color,
  282. padding: [0, 0, 0, 0],
  283. dataLabel: true,
  284. extra: {
  285. map: {
  286. border: true,
  287. borderWidth: 1,
  288. borderColor: "#666666",
  289. fillOpacity: 0.6,
  290. activeBorderColor: "#F04864",
  291. activeFillColor: "#FACC14",
  292. activeFillOpacity: 1,
  293. },
  294. },
  295. },
  296. arcbar: {
  297. type: "arcbar",
  298. color: color,
  299. title: {
  300. name: "百分比",
  301. fontSize: 25,
  302. color: "#00FF00",
  303. },
  304. subtitle: {
  305. name: "默认标题",
  306. fontSize: 15,
  307. color: "#666666",
  308. },
  309. extra: {
  310. arcbar: {
  311. type: "default",
  312. width: 12,
  313. backgroundColor: "#E9E9E9",
  314. startAngle: 0.75,
  315. endAngle: 0.25,
  316. gap: 2,
  317. },
  318. },
  319. },
  320. line: {
  321. type: "line",
  322. color: color,
  323. padding: [15, 10, 0, 15],
  324. xAxis: {
  325. disableGrid: true,
  326. },
  327. yAxis: {
  328. gridType: "dash",
  329. dashLength: 2,
  330. },
  331. legend: {},
  332. extra: {
  333. line: {
  334. type: "straight",
  335. width: 2,
  336. activeType: "hollow",
  337. },
  338. },
  339. },
  340. tline: {
  341. type: "line",
  342. color: color,
  343. padding: [15, 10, 0, 15],
  344. xAxis: {
  345. disableGrid: false,
  346. boundaryGap: "justify",
  347. },
  348. yAxis: {
  349. gridType: "dash",
  350. dashLength: 2,
  351. data: [
  352. {
  353. min: 0,
  354. max: 80,
  355. },
  356. ],
  357. },
  358. legend: {},
  359. extra: {
  360. line: {
  361. type: "curve",
  362. width: 2,
  363. activeType: "hollow",
  364. },
  365. },
  366. },
  367. tarea: {
  368. type: "area",
  369. color: color,
  370. padding: [15, 10, 0, 15],
  371. xAxis: {
  372. disableGrid: true,
  373. boundaryGap: "justify",
  374. },
  375. yAxis: {
  376. gridType: "dash",
  377. dashLength: 2,
  378. data: [
  379. {
  380. min: 0,
  381. max: 80,
  382. },
  383. ],
  384. },
  385. legend: {},
  386. extra: {
  387. area: {
  388. type: "curve",
  389. opacity: 0.2,
  390. addLine: true,
  391. width: 2,
  392. gradient: true,
  393. activeType: "hollow",
  394. },
  395. },
  396. },
  397. column: {
  398. type: "column",
  399. color: color,
  400. padding: [15, 15, 0, 5],
  401. xAxis: {
  402. disableGrid: true,
  403. },
  404. yAxis: {
  405. data: [{ min: 0 }],
  406. },
  407. legend: {},
  408. extra: {
  409. column: {
  410. type: "group",
  411. width: 30,
  412. activeBgColor: "#000000",
  413. activeBgOpacity: 0.08,
  414. },
  415. },
  416. },
  417. mount: {
  418. type: "mount",
  419. color: color,
  420. padding: [15, 15, 0, 5],
  421. xAxis: {
  422. disableGrid: true,
  423. },
  424. yAxis: {
  425. data: [{ min: 0 }],
  426. },
  427. legend: {},
  428. extra: {
  429. mount: {
  430. type: "mount",
  431. widthRatio: 1.5,
  432. },
  433. },
  434. },
  435. bar: {
  436. type: "bar",
  437. color: color,
  438. padding: [15, 30, 0, 5],
  439. xAxis: {
  440. boundaryGap: "justify",
  441. disableGrid: false,
  442. min: 0,
  443. axisLine: false,
  444. },
  445. yAxis: {},
  446. legend: {},
  447. extra: {
  448. bar: {
  449. type: "group",
  450. width: 30,
  451. meterBorde: 1,
  452. meterFillColor: "#FFFFFF",
  453. activeBgColor: "#000000",
  454. activeBgOpacity: 0.08,
  455. },
  456. },
  457. },
  458. area: {
  459. type: "area",
  460. color: color,
  461. padding: [15, 15, 0, 15],
  462. xAxis: {
  463. disableGrid: true,
  464. },
  465. yAxis: {
  466. gridType: "dash",
  467. dashLength: 2,
  468. },
  469. legend: {},
  470. extra: {
  471. area: {
  472. type: "straight",
  473. opacity: 0.2,
  474. addLine: true,
  475. width: 2,
  476. gradient: false,
  477. activeType: "hollow",
  478. },
  479. },
  480. },
  481. radar: {
  482. type: "radar",
  483. color: color,
  484. padding: [5, 5, 5, 5],
  485. dataLabel: false,
  486. legend: {
  487. show: true,
  488. position: "right",
  489. lineHeight: 25,
  490. },
  491. extra: {
  492. radar: {
  493. gridType: "radar",
  494. gridColor: "#CCCCCC",
  495. gridCount: 3,
  496. opacity: 0.2,
  497. max: 200,
  498. labelShow: true,
  499. },
  500. },
  501. },
  502. gauge: {
  503. type: "gauge",
  504. color: color,
  505. title: {
  506. name: "66Km/H",
  507. fontSize: 25,
  508. color: "#2fc25b",
  509. offsetY: 50,
  510. },
  511. subtitle: {
  512. name: "实时速度",
  513. fontSize: 15,
  514. color: "#1890ff",
  515. offsetY: -50,
  516. },
  517. extra: {
  518. gauge: {
  519. type: "default",
  520. width: 30,
  521. labelColor: "#666666",
  522. startAngle: 0.75,
  523. endAngle: 0.25,
  524. startNumber: 0,
  525. endNumber: 100,
  526. labelFormat: "",
  527. splitLine: {
  528. fixRadius: 0,
  529. splitNumber: 10,
  530. width: 30,
  531. color: "#FFFFFF",
  532. childNumber: 5,
  533. childWidth: 12,
  534. },
  535. pointer: {
  536. width: 24,
  537. color: "auto",
  538. },
  539. },
  540. },
  541. },
  542. candle: {
  543. type: "candle",
  544. color: color,
  545. padding: [15, 15, 0, 15],
  546. enableScroll: true,
  547. enableMarkLine: true,
  548. dataLabel: false,
  549. xAxis: {
  550. labelCount: 4,
  551. itemCount: 40,
  552. disableGrid: true,
  553. gridColor: "#CCCCCC",
  554. gridType: "solid",
  555. dashLength: 4,
  556. scrollShow: true,
  557. scrollAlign: "left",
  558. scrollColor: "#A6A6A6",
  559. scrollBackgroundColor: "#EFEBEF",
  560. },
  561. yAxis: {},
  562. legend: {},
  563. extra: {
  564. candle: {
  565. color: {
  566. upLine: "#f04864",
  567. upFill: "#f04864",
  568. downLine: "#2fc25b",
  569. downFill: "#2fc25b",
  570. },
  571. average: {
  572. show: true,
  573. name: ["MA5", "MA10", "MA30"],
  574. day: [5, 10, 20],
  575. color: ["#1890ff", "#2fc25b", "#facc14"],
  576. },
  577. },
  578. markLine: {
  579. type: "dash",
  580. dashLength: 5,
  581. data: [
  582. {
  583. value: 2150,
  584. lineColor: "#f04864",
  585. showLabel: true,
  586. },
  587. {
  588. value: 2350,
  589. lineColor: "#f04864",
  590. showLabel: true,
  591. },
  592. ],
  593. },
  594. },
  595. },
  596. mix: {
  597. type: "mix",
  598. color: color,
  599. padding: [15, 15, 0, 15],
  600. xAxis: {
  601. disableGrid: true,
  602. },
  603. yAxis: {
  604. disabled: false,
  605. disableGrid: false,
  606. splitNumber: 5,
  607. gridType: "dash",
  608. dashLength: 4,
  609. gridColor: "#CCCCCC",
  610. padding: 10,
  611. showTitle: true,
  612. data: [],
  613. },
  614. legend: {},
  615. extra: {
  616. mix: {
  617. column: {
  618. width: 20,
  619. },
  620. },
  621. },
  622. },
  623. scatter: {
  624. type: "scatter",
  625. color: color,
  626. padding: [15, 15, 0, 15],
  627. dataLabel: false,
  628. xAxis: {
  629. disableGrid: false,
  630. gridType: "dash",
  631. splitNumber: 5,
  632. boundaryGap: "justify",
  633. min: 0,
  634. },
  635. yAxis: {
  636. disableGrid: false,
  637. gridType: "dash",
  638. },
  639. legend: {},
  640. extra: {
  641. scatter: {},
  642. },
  643. },
  644. bubble: {
  645. type: "bubble",
  646. color: color,
  647. padding: [15, 15, 0, 15],
  648. xAxis: {
  649. disableGrid: false,
  650. gridType: "dash",
  651. splitNumber: 5,
  652. boundaryGap: "justify",
  653. min: 0,
  654. max: 250,
  655. },
  656. yAxis: {
  657. disableGrid: false,
  658. gridType: "dash",
  659. data: [
  660. {
  661. min: 0,
  662. max: 150,
  663. },
  664. ],
  665. },
  666. legend: {},
  667. extra: {
  668. bubble: {
  669. border: 2,
  670. opacity: 0.5,
  671. },
  672. },
  673. },
  674. };
  675. export default cfu;