config-ucharts.js 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676
  1. // 主题颜色配置:如每个图表类型需要不同主题,请在对应图表类型上更改color属性
  2. const color = ["#4169E1", "#ff5959", "#f9c752", "#d8deff", "#23b46c", "#ff8caf", "#FC8452", "#9A60B4"];
  3. // 提示窗配置
  4. const tooltip = {
  5. "showBox": true,
  6. "showArrow": false,
  7. "showCategory": false,
  8. "borderRadius": 6,
  9. "bgOpacity": 0.5,
  10. "splitLine": true,
  11. "gridType": "dash",
  12. "dashLength": 24,
  13. };
  14. //x轴配置
  15. const X = {
  16. "disableGrid": true,
  17. "fontSize": 11,
  18. "scrollColor": "#F5F5F5",
  19. "scrollBackgroundColor": "#D3D3D3",
  20. "itemCount": 6,
  21. "format": ""
  22. };
  23. //y轴配置
  24. const Y = {
  25. "data": [{
  26. // "fontSize": 11,
  27. // "min": 0,
  28. axisLine: false,
  29. }]
  30. };
  31. //图例配置
  32. const legend = {
  33. "show": true,
  34. "position": "top",
  35. "float": "right",
  36. "padding": 5,
  37. "margin": 15,
  38. "fontSize": 13,
  39. };
  40. //标记线配置
  41. const markLine = {
  42. "type": "solid",
  43. "dashLength": 20,
  44. "data": [{
  45. "value": 100,
  46. "lineColor": "#666",
  47. "showLabel": true,
  48. "labelFontColor": "#666",
  49. "labelBgColor": "#FFF",
  50. "labelBgOpacity": 0,
  51. "yAxisIndex": 0
  52. }]
  53. };
  54. const padding = [
  55. 0, 10, 20, 5
  56. ]
  57. //事件转换函数,主要用作格式化x轴为时间轴,根据需求自行修改
  58. const formatDateTime = (timeStamp, returnType) => {
  59. var date = new Date();
  60. date.setTime(timeStamp * 1000);
  61. var y = date.getFullYear();
  62. var m = date.getMonth() + 1;
  63. m = m < 10 ? ('0' + m) : m;
  64. var d = date.getDate();
  65. d = d < 10 ? ('0' + d) : d;
  66. var h = date.getHours();
  67. h = h < 10 ? ('0' + h) : h;
  68. var minute = date.getMinutes();
  69. var second = date.getSeconds();
  70. minute = minute < 10 ? ('0' + minute) : minute;
  71. second = second < 10 ? ('0' + second) : second;
  72. if (returnType == 'full') {
  73. return y + '-' + m + '-' + d + ' ' + h + ':' + minute + ':' + second;
  74. }
  75. if (returnType == 'y-m-d') {
  76. return y + '-' + m + '-' + d;
  77. }
  78. if (returnType == 'h:m') {
  79. return h + ':' + minute;
  80. }
  81. if (returnType == 'h:m:s') {
  82. return h + ':' + minute + ':' + second;
  83. }
  84. return [y, m, d, h, minute, second];
  85. }
  86. const cfu = {
  87. //demotype为自定义图表类型,一般不需要自定义图表类型,只需要改根节点上对应的类型即可
  88. "type": ["pie", "ring", "rose", "arcbar", "line", "column", "area", "radar", "mainline", "mini-line",
  89. "mini-area", "mini-column", "mini-rose", "mount", "bar"
  90. ],
  91. "range": [],
  92. //增加自定义图表类型,如果需要categories,请在这里加入您的图表类型,例如最后的"demotype"
  93. //自定义类型时需要注意"tline","tarea","scatter","bubble"等时间轴(矢量x轴)类图表,没有categories,不需要加入categories
  94. "categories": ["line", "column", "bar", "area", "radar", "mainline", "mini-line", "mini-area", "mini-column",
  95. "mount", "bar"
  96. ],
  97. //instance为实例变量承载属性,不要删除
  98. "instance": {},
  99. //option为opts及eopts承载属性,不要删除
  100. "option": {},
  101. //下面是自定义format配置,因除H5端外的其他端无法通过props传递函数,只能通过此属性对应下标的方式来替换
  102. "formatter": {
  103. "tooltipScore": function(item, category, index, opts) {
  104. return category + ' ' + item.name + ': ' + item.data + ' 分 '
  105. },
  106. "tooltipScoreShort": function(item, category, index, opts) {
  107. return item.name + '得分率: ' + item.data + ' % '
  108. },
  109. "HomeworkPercent": function(item, category, index, opts) {
  110. return category.replace('-', '月') + '日 ' + item.name + ' ' + item.data + ' % '
  111. },
  112. "tooltipHourColum": function(item, category, index, opts) {
  113. return category.replace('-', '月') + '日 ' + item.name + ': ' + item.data + ' 小时 '
  114. },
  115. "pieHour": function(item, category, index, opts) {
  116. return item.name.replace('-', '月') + '日 ' + item.data + '小时'
  117. },
  118. "pieMinute": function(item, category, index, opts) {
  119. return item.name.replace('-', '月') + '日 ' + item.data + '分钟'
  120. },
  121. "sleepExerciseCom": function(item, category, index, opts) {
  122. let value = item.data <= 20 ? (item.data >= 10 ? '分配科学' : '运动量少') : '运动过量'
  123. return '运动占睡眠: ' + item.data + '% ' + value
  124. },
  125. "subjectRankColum": function(item, category, index, opts) {
  126. return category + ' ' + item.name + '超过 ' + item.data + '% 的学生'
  127. },
  128. "subjectRankArea": function(item, category, index, opts) {
  129. return category + ' ' + item.name + item.data + '% 的学生'
  130. },
  131. "distributionColumn": function(item, category, index, opts) {
  132. return category + '分 ' + item.name + ' ' + item.data + ' 人 '
  133. },
  134. "meritsRadar": function(item, category, index, opts) {
  135. return category + ' ' + item.name + ' ' + item.data + ' % '
  136. },
  137. "xAxisBar": function(val, index, opts) {
  138. return parseInt(val).toFixed(0) + '%'
  139. },
  140. },
  141. //这里演示了自定义您的图表类型的option,可以随意命名,之后在组件上 type="demotype" 后,组件会调用这个花括号里的option,如果组件上还存在opts参数,会将demotype与opts中option合并后渲染图表。
  142. //下面是自定义配置,请添加项目所需的通用配置
  143. "line": {
  144. "type": "line",
  145. "animation": true,
  146. "timing": "easeOut",
  147. "duration": 500,
  148. "color": color,
  149. "padding": padding,
  150. "dataLabel": false,
  151. "fontSize": 12,
  152. "xAxis": X,
  153. "yAxis": Y,
  154. "enableScroll": true,
  155. "touchMoveLimit": 60,
  156. "legend": legend,
  157. "extra": {
  158. "line": {
  159. "type": "curve",
  160. "width": 2
  161. },
  162. "tooltip": tooltip,
  163. }
  164. },
  165. "column": {
  166. "type": "column",
  167. "animation": true,
  168. "timing": "easeOut",
  169. "duration": 500,
  170. "color": color,
  171. "padding": padding,
  172. "dataLabel": false,
  173. "fontSize": 12,
  174. "xAxis": X,
  175. "yAxis": Y,
  176. "enableScroll": true,
  177. "touchMoveLimit": 60,
  178. "legend": legend,
  179. "extra": {
  180. "column": {
  181. "type": "group",
  182. "width": 17,
  183. "seriesGap": 3,
  184. "categoryGap": 5,
  185. "barBorderCircle": true,
  186. },
  187. "tooltip": tooltip,
  188. }
  189. },
  190. "area": {
  191. "type": "area",
  192. "animation": true,
  193. "timing": "easeOut",
  194. "duration": 500,
  195. "color": color,
  196. "padding": padding,
  197. "dataLabel": false,
  198. "fontSize": 12,
  199. "xAxis": X,
  200. "yAxis": Y,
  201. "enableScroll": true,
  202. "touchMoveLimit": 60,
  203. "legend": legend,
  204. "extra": {
  205. "area": {
  206. "type": "curve",
  207. "opacity": 0.5,
  208. "addLine": true,
  209. "width": 2,
  210. "gradient": true
  211. },
  212. "tooltip": tooltip,
  213. }
  214. },
  215. "rose": {
  216. "type": "rose",
  217. "animation": true,
  218. "timing": "easeOut",
  219. "duration": 500,
  220. "color": color,
  221. "padding": [
  222. -20,
  223. 5,
  224. 5,
  225. 5
  226. ],
  227. "dataLabel": false,
  228. "dataPointShape": false,
  229. "dataPointShapeType": "hollow",
  230. "legend": {
  231. "show": true,
  232. "position": "bottom",
  233. "float": "center",
  234. },
  235. "extra": {
  236. "rose": {
  237. "type": "radius",
  238. "minRadius": 90,
  239. "border": true,
  240. },
  241. "tooltip": tooltip,
  242. }
  243. },
  244. "arcbar": {
  245. "type": "arcbar",
  246. "animation": true,
  247. "timing": "easeOut",
  248. "duration": 500,
  249. "padding": [30, 30, 30, 30],
  250. "title": {
  251. "name": "",
  252. "fontSize": 28,
  253. "color": "#4169E1",
  254. "offsetY": -5
  255. },
  256. "subtitle": {
  257. "name": "",
  258. "fontSize": 15,
  259. "color": "#909399",
  260. },
  261. "extra": {
  262. "arcbar": {
  263. "width": 15,
  264. "type": "circle",
  265. "backgroundColor": "#F5F5F5",
  266. }
  267. }
  268. },
  269. "radar": {
  270. "type": "radar",
  271. "animation": true,
  272. "timing": "easeOut",
  273. "duration": 500,
  274. "color": color,
  275. "padding": [
  276. 0, 15, 10, 15
  277. ],
  278. "fontSize": 13,
  279. "enableMarkLine": false,
  280. "dataLabel": false,
  281. "legend": {
  282. "show": true,
  283. "position": "top",
  284. "float": "center",
  285. "padding": 5,
  286. "margin": 5,
  287. "fontColor": "#696969",
  288. },
  289. "extra": {
  290. "radar": {
  291. "gridType": "circle",
  292. "gridCount": 3,
  293. "opacity": 0.2,
  294. "border": true,
  295. "borderWidth": 1,
  296. "labelColor": '#303133',
  297. "labelPointShow": true,
  298. },
  299. "tooltip": tooltip,
  300. }
  301. },
  302. "pie": {
  303. "type": "pie",
  304. "animation": true,
  305. "timing": "easeOut",
  306. "duration": 500,
  307. "color": color,
  308. "padding": [
  309. 0, 3, 0, 3
  310. ],
  311. "fontSize": 12,
  312. "dataLabel": false,
  313. "legend": {
  314. "show": false,
  315. },
  316. "extra": {
  317. "pie": {
  318. "activeOpacity": 0.5,
  319. "activeRadius": 10,
  320. "offsetAngle": 0,
  321. "customRadius": 0,
  322. "labelWidth": 15,
  323. "border": true,
  324. "borderWidth": 3,
  325. "borderColor": "#FFFFFF",
  326. "linearType": "none"
  327. },
  328. "tooltip": tooltip,
  329. }
  330. },
  331. "ring": {
  332. "type": "ring",
  333. "animation": true,
  334. "timing": "easeOut",
  335. "duration": 500,
  336. "color": color,
  337. "padding": [
  338. 0, 3, 0, 3
  339. ],
  340. "fontSize": 12,
  341. "dataLabel": false,
  342. "legend": {
  343. "show": false,
  344. },
  345. "title": {
  346. "name": "",
  347. "fontSize": 12,
  348. "offsetY": -5
  349. },
  350. "subtitle": {
  351. "name": "",
  352. "fontSize": 16,
  353. },
  354. "extra": {
  355. "ring": {
  356. "ringWidth": 30,
  357. "centerColor": "#FFFFFF",
  358. "activeOpacity": 0.5,
  359. "activeRadius": 10,
  360. "offsetAngle": 0,
  361. "customRadius": 0,
  362. "labelWidth": 15,
  363. "border": true,
  364. "borderWidth": 3,
  365. "borderColor": "#FFFFFF",
  366. "linearType": "none"
  367. },
  368. "tooltip": tooltip,
  369. }
  370. },
  371. "mainline": {
  372. "type": "area",
  373. "animation": true,
  374. "timing": "easeOut",
  375. "duration": 500,
  376. "color": color,
  377. "padding": [
  378. 0,
  379. -20,
  380. 10,
  381. -20
  382. ],
  383. "dataLabel": false,
  384. "dataPointShape": false,
  385. "tapLegend": false,
  386. "xAxis": {
  387. "disabled": true,
  388. "axisLine": false,
  389. "disableGrid": true,
  390. },
  391. "yAxis": {
  392. "disabled": true,
  393. "disableGrid": true
  394. },
  395. "legend": {
  396. "show": false,
  397. },
  398. "extra": {
  399. "area": {
  400. "type": "curve",
  401. "opacity": 0.7,
  402. "addLine": true,
  403. "width": 3,
  404. "gradient": true
  405. },
  406. "tooltip": {
  407. "showBox": false,
  408. "splitLine": false,
  409. },
  410. }
  411. },
  412. "mini-column": {
  413. "type": "column",
  414. "animation": true,
  415. "timing": "easeOut",
  416. "duration": 500,
  417. "color": color,
  418. "padding": [
  419. 0,
  420. 10,
  421. 10,
  422. 10
  423. ],
  424. "dataLabel": false,
  425. "dataPointShape": false,
  426. "tapLegend": false,
  427. "xAxis": {
  428. "disabled": true,
  429. "axisLine": false,
  430. "disableGrid": true,
  431. },
  432. "yAxis": {
  433. "disabled": true,
  434. "disableGrid": true,
  435. },
  436. "legend": {
  437. "show": false,
  438. },
  439. "extra": {
  440. "column": {
  441. "type": "group",
  442. "width": 10,
  443. "seriesGap": 2,
  444. "categoryGap": 3,
  445. "barBorderCircle": false,
  446. "barBorderRadius": [
  447. 10,
  448. 10,
  449. 10,
  450. 10
  451. ],
  452. "linearType": "opacity",
  453. "linearOpacity": 0.7,
  454. "customColor": [
  455. "#4169E1",
  456. "#FFFFFF",
  457. "#ff5959",
  458. "#FFFFFF",
  459. "#f9c752",
  460. "#FFFFFF"
  461. ],
  462. "colorStop": 0.5,
  463. "meterBorder": 1,
  464. "meterFillColor": "#FFFFFF",
  465. "activeBgColor": "#FFFFFF",
  466. "activeBgOpacity": 0.08,
  467. "meterBorde": 1
  468. },
  469. "tooltip": {
  470. "showBox": false,
  471. "splitLine": false,
  472. },
  473. }
  474. },
  475. "mini-area": {
  476. "type": "area",
  477. "animation": true,
  478. "timing": "easeOut",
  479. "duration": 500,
  480. "color": color,
  481. "padding": [
  482. 0,
  483. -5,
  484. 10,
  485. -5
  486. ],
  487. "dataLabel": false,
  488. "dataPointShape": false,
  489. "tapLegend": false,
  490. "xAxis": {
  491. "disabled": true,
  492. "axisLine": false,
  493. "disableGrid": true,
  494. },
  495. "yAxis": {
  496. "disabled": true,
  497. "disableGrid": true,
  498. },
  499. "legend": {
  500. "show": false,
  501. },
  502. "extra": {
  503. "area": {
  504. "type": "curve",
  505. "opacity": 0.7,
  506. "addLine": true,
  507. "width": 2,
  508. "gradient": true
  509. },
  510. "tooltip": {
  511. "showBox": false,
  512. "splitLine": false,
  513. },
  514. },
  515. },
  516. "mini-rose": {
  517. "type": "rose",
  518. "animation": true,
  519. "timing": "easeOut",
  520. "duration": 500,
  521. "color": color,
  522. "padding": [
  523. 0,
  524. 0,
  525. 0,
  526. 0
  527. ],
  528. "dataLabel": false,
  529. "dataPointShape": false,
  530. "dataPointShapeType": "hollow",
  531. "legend": {
  532. "show": false,
  533. },
  534. "extra": {
  535. "rose": {
  536. "type": "radius",
  537. "minRadius": 40,
  538. "activeRadius": 0,
  539. "opacity": 0.7,
  540. "gradient": true,
  541. "border": true,
  542. "borderWidth": 2,
  543. "borderColor": "#FFFFFF",
  544. },
  545. "tooltip": {
  546. "showBox": false,
  547. "splitLine": false,
  548. },
  549. },
  550. },
  551. "mount": {
  552. "type": "mount",
  553. "animation": true,
  554. "timing": "easeOut",
  555. "duration": 500,
  556. "color": color,
  557. "padding": [
  558. 0,
  559. 20,
  560. 10,
  561. 20
  562. ],
  563. "dataLabel": false,
  564. "dataPointShape": false,
  565. "tapLegend": false,
  566. "xAxis": {
  567. "disableGrid": true,
  568. "fontSize": 11,
  569. "scrollColor": "#F5F5F5",
  570. "scrollBackgroundColor": "#D3D3D3",
  571. "boundaryGap": "center",
  572. "disabled": true
  573. },
  574. "yAxis": {
  575. "disableGrid": true,
  576. "data": [{
  577. "fontSize": 11,
  578. "min": 0,
  579. "disabled": true
  580. }]
  581. },
  582. "legend": {
  583. "show": false,
  584. },
  585. "extra": {
  586. "mount": {
  587. "type": "mount",
  588. "borderWidth": 1.2,
  589. "widthRatio": 1.7,
  590. "linearType": "opacity",
  591. "linearOpacity": 0.1
  592. },
  593. "tooltip": {
  594. "showBox": true,
  595. "showArrow": false,
  596. "showCategory": false,
  597. "borderRadius": 6,
  598. "bgOpacity": 0.5,
  599. "splitLine": false,
  600. },
  601. }
  602. },
  603. "bar": {
  604. "type": "bar",
  605. "timing": "easeOut",
  606. "duration": 1000,
  607. "rotate": false,
  608. "rotateLock": false,
  609. "color": color,
  610. "padding": [0, 30, 20, 10],
  611. "fontSize": 13,
  612. "fontColor": "#666666",
  613. "dataLabel": false,
  614. "dataPointShape": true,
  615. "dataPointShapeType": "solid",
  616. "touchMoveLimit": 60,
  617. "enableScroll": false,
  618. "enableMarkLine": false,
  619. "xAxis": {
  620. "boundaryGap": "justify",
  621. "disableGrid": false,
  622. "min": 0,
  623. "max": 100,
  624. "axisLine": false,
  625. "disabled": false,
  626. "axisLineColor": "#CCCCCC",
  627. "calibration": false,
  628. "fontColor": "#666666",
  629. "fontSize": 13,
  630. "rotateLabel": false,
  631. "rotateAngle": 45,
  632. "itemCount": 5,
  633. "splitNumber": 5,
  634. "gridColor": "#CCCCCC",
  635. "gridType": "dash",
  636. "dashLength": 10,
  637. "gridEval": 1,
  638. "scrollShow": false,
  639. "scrollAlign": "left",
  640. "scrollColor": "#A6A6A6",
  641. "scrollBackgroundColor": "#EFEBEF",
  642. "format": ""
  643. },
  644. "yAxis": {
  645. "disabled": false,
  646. "disableGrid": false,
  647. "splitNumber": 5,
  648. "gridType": "solid",
  649. "dashLength": 8,
  650. "gridColor": "#CCCCCC",
  651. "padding": 10,
  652. "showTitle": false,
  653. "data": []
  654. },
  655. "extra": {
  656. "bar": {
  657. "type": "group",
  658. "width": 30,
  659. "meterBorde": 1,
  660. "activeBgOpacity": 0.08,
  661. "seriesGap": 2,
  662. "categoryGap": 3,
  663. "barBorderCircle": false,
  664. "barBorderRadius": [6, 6, 6, 6],
  665. "linearType": "none",
  666. "linearOpacity": 1,
  667. "colorStop": 0
  668. },
  669. "tooltip": tooltip,
  670. }
  671. }
  672. }
  673. export default cfu;