config-ucharts.js 13 KB

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