config-ucharts.js 12 KB

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