config-ucharts.js 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604
  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"
  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"
  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. },
  138. //这里演示了自定义您的图表类型的option,可以随意命名,之后在组件上 type="demotype" 后,组件会调用这个花括号里的option,如果组件上还存在opts参数,会将demotype与opts中option合并后渲染图表。
  139. //下面是自定义配置,请添加项目所需的通用配置
  140. "line": {
  141. "type": "line",
  142. "animation": true,
  143. "timing": "easeOut",
  144. "duration": 500,
  145. "color": color,
  146. "padding": padding,
  147. "dataLabel": false,
  148. "fontSize": 12,
  149. "xAxis": X,
  150. "yAxis": Y,
  151. "enableScroll": true,
  152. "touchMoveLimit": 60,
  153. "legend": legend,
  154. "extra": {
  155. "line": {
  156. "type": "curve",
  157. "width": 2
  158. },
  159. "tooltip": tooltip,
  160. }
  161. },
  162. "column": {
  163. "type": "column",
  164. "animation": true,
  165. "timing": "easeOut",
  166. "duration": 500,
  167. "color": color,
  168. "padding": padding,
  169. "dataLabel": false,
  170. "fontSize": 12,
  171. "xAxis": X,
  172. "yAxis": Y,
  173. "enableScroll": true,
  174. "touchMoveLimit": 60,
  175. "legend": legend,
  176. "extra": {
  177. "column": {
  178. "type": "group",
  179. "width": 17,
  180. "seriesGap": 3,
  181. "categoryGap": 5,
  182. "barBorderCircle": true,
  183. },
  184. "tooltip": tooltip,
  185. }
  186. },
  187. "area": {
  188. "type": "area",
  189. "animation": true,
  190. "timing": "easeOut",
  191. "duration": 500,
  192. "color": color,
  193. "padding": padding,
  194. "dataLabel": false,
  195. "fontSize": 12,
  196. "xAxis": X,
  197. "yAxis": Y,
  198. "enableScroll": true,
  199. "touchMoveLimit": 60,
  200. "legend": legend,
  201. "extra": {
  202. "area": {
  203. "type": "curve",
  204. "opacity": 0.5,
  205. "addLine": true,
  206. "width": 2,
  207. "gradient": true
  208. },
  209. "tooltip": tooltip,
  210. }
  211. },
  212. "rose": {
  213. "type": "rose",
  214. "animation": true,
  215. "timing": "easeOut",
  216. "duration": 500,
  217. "color": color,
  218. "padding": [
  219. -20,
  220. 5,
  221. 5,
  222. 5
  223. ],
  224. "dataLabel": false,
  225. "dataPointShape": false,
  226. "dataPointShapeType": "hollow",
  227. "legend": {
  228. "show": true,
  229. "position": "bottom",
  230. "float": "center",
  231. },
  232. "extra": {
  233. "rose": {
  234. "type": "radius",
  235. "minRadius": 90,
  236. "border": true,
  237. },
  238. "tooltip": tooltip,
  239. }
  240. },
  241. "arcbar": {
  242. "type": "arcbar",
  243. "animation": true,
  244. "timing": "easeOut",
  245. "duration": 500,
  246. "padding": [30, 30, 30, 30],
  247. "title": {
  248. "name": "",
  249. "fontSize": 28,
  250. "color": "#4169E1",
  251. "offsetY": -5
  252. },
  253. "subtitle": {
  254. "name": "",
  255. "fontSize": 15,
  256. "color": "#909399",
  257. },
  258. "extra": {
  259. "arcbar": {
  260. "width": 15,
  261. "type": "circle",
  262. "backgroundColor": "#F5F5F5",
  263. }
  264. }
  265. },
  266. "radar": {
  267. "type": "radar",
  268. "animation": true,
  269. "timing": "easeOut",
  270. "duration": 500,
  271. "color": color,
  272. "padding": [
  273. 0, 15, 10, 15
  274. ],
  275. "fontSize": 13,
  276. "enableMarkLine": false,
  277. "dataLabel": false,
  278. "legend": {
  279. "show": true,
  280. "position": "top",
  281. "float": "center",
  282. "padding": 5,
  283. "margin": 5,
  284. "fontColor": "#696969",
  285. },
  286. "extra": {
  287. "radar": {
  288. "gridType": "circle",
  289. "gridCount": 3,
  290. "opacity": 0.2,
  291. "border": true,
  292. "borderWidth": 1,
  293. "labelColor": '#303133',
  294. "labelPointShow": true,
  295. },
  296. "tooltip": tooltip,
  297. }
  298. },
  299. "pie": {
  300. "type": "pie",
  301. "animation": true,
  302. "timing": "easeOut",
  303. "duration": 500,
  304. "color": color,
  305. "padding": [
  306. 0, 3, 0, 3
  307. ],
  308. "fontSize": 12,
  309. "dataLabel": false,
  310. "legend": {
  311. "show": false,
  312. },
  313. "extra": {
  314. "pie": {
  315. "activeOpacity": 0.5,
  316. "activeRadius": 10,
  317. "offsetAngle": 0,
  318. "customRadius": 0,
  319. "labelWidth": 15,
  320. "border": true,
  321. "borderWidth": 3,
  322. "borderColor": "#FFFFFF",
  323. "linearType": "none"
  324. },
  325. "tooltip": tooltip,
  326. }
  327. },
  328. "ring": {
  329. "type": "ring",
  330. "animation": true,
  331. "timing": "easeOut",
  332. "duration": 500,
  333. "color": color,
  334. "padding": [
  335. 0, 3, 0, 3
  336. ],
  337. "fontSize": 12,
  338. "dataLabel": false,
  339. "legend": {
  340. "show": false,
  341. },
  342. "title": {
  343. "name": "",
  344. "fontSize": 12,
  345. "offsetY": -5
  346. },
  347. "subtitle": {
  348. "name": "",
  349. "fontSize": 16,
  350. },
  351. "extra": {
  352. "ring": {
  353. "ringWidth": 30,
  354. "centerColor": "#FFFFFF",
  355. "activeOpacity": 0.5,
  356. "activeRadius": 10,
  357. "offsetAngle": 0,
  358. "customRadius": 0,
  359. "labelWidth": 15,
  360. "border": true,
  361. "borderWidth": 3,
  362. "borderColor": "#FFFFFF",
  363. "linearType": "none"
  364. },
  365. "tooltip": tooltip,
  366. }
  367. },
  368. "mainline": {
  369. "type": "area",
  370. "animation": true,
  371. "timing": "easeOut",
  372. "duration": 500,
  373. "color": color,
  374. "padding": [
  375. 0,
  376. -20,
  377. 10,
  378. -20
  379. ],
  380. "dataLabel": false,
  381. "dataPointShape": false,
  382. "tapLegend": false,
  383. "xAxis": {
  384. "disabled": true,
  385. "axisLine": false,
  386. "disableGrid": true,
  387. },
  388. "yAxis": {
  389. "disabled": true,
  390. "disableGrid": true
  391. },
  392. "legend": {
  393. "show": false,
  394. },
  395. "extra": {
  396. "area": {
  397. "type": "curve",
  398. "opacity": 0.7,
  399. "addLine": true,
  400. "width": 3,
  401. "gradient": true
  402. },
  403. "tooltip": {
  404. "showBox": false,
  405. "splitLine": false,
  406. },
  407. }
  408. },
  409. "mini-column": {
  410. "type": "column",
  411. "animation": true,
  412. "timing": "easeOut",
  413. "duration": 500,
  414. "color": color,
  415. "padding": [
  416. 0,
  417. 10,
  418. 10,
  419. 10
  420. ],
  421. "dataLabel": false,
  422. "dataPointShape": false,
  423. "tapLegend": false,
  424. "xAxis": {
  425. "disabled": true,
  426. "axisLine": false,
  427. "disableGrid": true,
  428. },
  429. "yAxis": {
  430. "disabled": true,
  431. "disableGrid": true,
  432. },
  433. "legend": {
  434. "show": false,
  435. },
  436. "extra": {
  437. "column": {
  438. "type": "group",
  439. "width": 10,
  440. "seriesGap": 2,
  441. "categoryGap": 3,
  442. "barBorderCircle": false,
  443. "barBorderRadius": [
  444. 10,
  445. 10,
  446. 10,
  447. 10
  448. ],
  449. "linearType": "opacity",
  450. "linearOpacity": 0.7,
  451. "customColor": [
  452. "#4169E1",
  453. "#FFFFFF",
  454. "#ff5959",
  455. "#FFFFFF",
  456. "#f9c752",
  457. "#FFFFFF"
  458. ],
  459. "colorStop": 0.5,
  460. "meterBorder": 1,
  461. "meterFillColor": "#FFFFFF",
  462. "activeBgColor": "#FFFFFF",
  463. "activeBgOpacity": 0.08,
  464. "meterBorde": 1
  465. },
  466. "tooltip": {
  467. "showBox": false,
  468. "splitLine": false,
  469. },
  470. }
  471. },
  472. "mini-area": {
  473. "type": "area",
  474. "animation": true,
  475. "timing": "easeOut",
  476. "duration": 500,
  477. "color": color,
  478. "padding": [
  479. 0,
  480. -5,
  481. 10,
  482. -5
  483. ],
  484. "dataLabel": false,
  485. "dataPointShape": false,
  486. "tapLegend": false,
  487. "xAxis": {
  488. "disabled": true,
  489. "axisLine": false,
  490. "disableGrid": true,
  491. },
  492. "yAxis": {
  493. "disabled": true,
  494. "disableGrid": true,
  495. },
  496. "legend": {
  497. "show": false,
  498. },
  499. "extra": {
  500. "area": {
  501. "type": "curve",
  502. "opacity": 0.7,
  503. "addLine": true,
  504. "width": 2,
  505. "gradient": true
  506. },
  507. "tooltip": {
  508. "showBox": false,
  509. "splitLine": false,
  510. },
  511. },
  512. },
  513. "mini-rose": {
  514. "type": "rose",
  515. "animation": true,
  516. "timing": "easeOut",
  517. "duration": 500,
  518. "color": color,
  519. "padding": [
  520. 0,
  521. 0,
  522. 0,
  523. 0
  524. ],
  525. "dataLabel": false,
  526. "dataPointShape": false,
  527. "dataPointShapeType": "hollow",
  528. "legend": {
  529. "show": false,
  530. },
  531. "extra": {
  532. "rose": {
  533. "type": "radius",
  534. "minRadius": 40,
  535. "activeRadius": 0,
  536. "opacity": 0.7,
  537. "gradient": true,
  538. "border": true,
  539. "borderWidth": 2,
  540. "borderColor": "#FFFFFF",
  541. },
  542. "tooltip": {
  543. "showBox": false,
  544. "splitLine": false,
  545. },
  546. },
  547. },
  548. "mount": {
  549. "type": "mount",
  550. "animation": true,
  551. "timing": "easeOut",
  552. "duration": 500,
  553. "color": color,
  554. "padding": [
  555. 0,
  556. 20,
  557. 10,
  558. 20
  559. ],
  560. "dataLabel": false,
  561. "dataPointShape": false,
  562. "tapLegend": false,
  563. "xAxis": {
  564. "disableGrid": true,
  565. "fontSize": 11,
  566. "scrollColor": "#F5F5F5",
  567. "scrollBackgroundColor": "#D3D3D3",
  568. "boundaryGap": "center",
  569. "disabled": true
  570. },
  571. "yAxis": {
  572. "disableGrid": true,
  573. "data": [{
  574. "fontSize": 11,
  575. "min": 0,
  576. "disabled": true
  577. }]
  578. },
  579. "legend": {
  580. "show": false,
  581. },
  582. "extra": {
  583. "mount": {
  584. "type": "mount",
  585. "borderWidth": 1.2,
  586. "widthRatio": 1.7,
  587. "linearType": "opacity",
  588. "linearOpacity": 0.1
  589. },
  590. "tooltip": {
  591. "showBox": true,
  592. "showArrow": false,
  593. "showCategory": false,
  594. "borderRadius": 6,
  595. "bgOpacity": 0.5,
  596. "splitLine": false,
  597. },
  598. }
  599. }
  600. }
  601. export default cfu;