config-ucharts.js 12 KB

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