config-ucharts.js 12 KB

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