config-ucharts.js 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577
  1. // 主题颜色配置:如每个图表类型需要不同主题,请在对应图表类型上更改color属性
  2. const color = ["#0052d4", "#ff5959", "#f9b248", "#c1cbf7", "#3CA272", "#5fb7ff", "#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. //事件转换函数,主要用作格式化x轴为时间轴,根据需求自行修改
  51. const formatDateTime = (timeStamp, returnType) => {
  52. var date = new Date();
  53. date.setTime(timeStamp * 1000);
  54. var y = date.getFullYear();
  55. var m = date.getMonth() + 1;
  56. m = m < 10 ? ('0' + m) : m;
  57. var d = date.getDate();
  58. d = d < 10 ? ('0' + d) : d;
  59. var h = date.getHours();
  60. h = h < 10 ? ('0' + h) : h;
  61. var minute = date.getMinutes();
  62. var second = date.getSeconds();
  63. minute = minute < 10 ? ('0' + minute) : minute;
  64. second = second < 10 ? ('0' + second) : second;
  65. if (returnType == 'full') {
  66. return y + '-' + m + '-' + d + ' ' + h + ':' + minute + ':' + second;
  67. }
  68. if (returnType == 'y-m-d') {
  69. return y + '-' + m + '-' + d;
  70. }
  71. if (returnType == 'h:m') {
  72. return h + ':' + minute;
  73. }
  74. if (returnType == 'h:m:s') {
  75. return h + ':' + minute + ':' + second;
  76. }
  77. return [y, m, d, h, minute, second];
  78. }
  79. const cfu = {
  80. //demotype为自定义图表类型,一般不需要自定义图表类型,只需要改根节点上对应的类型即可
  81. "type": ["pie", "ring", "rose", "arcbar", "line", "column", "area", "radar", "mainline", "mini-line",
  82. "mini-area", "mini-column", "mini-rose", "fin-area"
  83. ],
  84. "range": [],
  85. //增加自定义图表类型,如果需要categories,请在这里加入您的图表类型,例如最后的"demotype"
  86. //自定义类型时需要注意"tline","tarea","scatter","bubble"等时间轴(矢量x轴)类图表,没有categories,不需要加入categories
  87. "categories": ["line", "column", "bar", "area", "radar", "mainline", "mini-line", "mini-area", "mini-column",
  88. "fin-area"
  89. ],
  90. //instance为实例变量承载属性,不要删除
  91. "instance": {},
  92. //option为opts及eopts承载属性,不要删除
  93. "option": {},
  94. //下面是自定义format配置,因除H5端外的其他端无法通过props传递函数,只能通过此属性对应下标的方式来替换
  95. "formatter": {
  96. "yAxisDemo1": function(val) {
  97. return val + '元'
  98. },
  99. "yAxisDemo2": function(val) {
  100. return val.toFixed(2)
  101. },
  102. "xAxisDemo1": function(val) {
  103. return val + '年'
  104. },
  105. "xAxisDemo2": function(val) {
  106. return formatDateTime(val, 'h:m')
  107. },
  108. "seriesDemo1": function(val) {
  109. return val + '元'
  110. },
  111. "tooltipScore": function(item, category, index, opts) {
  112. return category + ' ' + item.name + ': ' + item.data + ' 分 '
  113. },
  114. "tooltipScoreShort": function(item, category, index, opts) {
  115. return item.name + '得分率: ' + item.data + ' % '
  116. },
  117. "tooltipPercent": function(item, category, index, opts) {
  118. return category + ' ' + item.name + ': ' + item.data + ' % '
  119. },
  120. "HomeworkPercent": function(item, category, index, opts) {
  121. let value = item.data >= 50? (item.data >= 80? '优秀' : '良好') : '一般'
  122. return category + ' ' + item.name + '完成情况:' + value+ ' ' + item.data + ' % '
  123. },
  124. "tooltipHour": function(item, category, index, opts) {
  125. return item.name + ': ' + item.data + ' 小时 '
  126. },
  127. "pieMinute": function(item, category, index, opts) {
  128. return item.name + ': ' + item.data + ' 分钟 '
  129. },
  130. },
  131. //这里演示了自定义您的图表类型的option,可以随意命名,之后在组件上 type="demotype" 后,组件会调用这个花括号里的option,如果组件上还存在opts参数,会将demotype与opts中option合并后渲染图表。
  132. //下面是自定义配置,请添加项目所需的通用配置
  133. "line": {
  134. "type": "line",
  135. "animation": true,
  136. "timing": "easeOut",
  137. "duration": 500,
  138. "color": color,
  139. "padding": [
  140. 0, 10, 15, 5
  141. ],
  142. "dataLabel": false,
  143. "fontSize": 12,
  144. "xAxis": X,
  145. "yAxis": Y,
  146. "legend": legend,
  147. "extra": {
  148. "line": {
  149. "type": "curve",
  150. "width": 2
  151. },
  152. "tooltip": tooltip,
  153. }
  154. },
  155. "column": {
  156. "type": "column",
  157. "animation": true,
  158. "timing": "easeOut",
  159. "duration": 500,
  160. "color": color,
  161. "padding": [
  162. 0, 10, 15, 5
  163. ],
  164. "dataLabel": false,
  165. "fontSize": 12,
  166. "xAxis": X,
  167. "yAxis": Y,
  168. "legend": legend,
  169. "extra": {
  170. "column": {
  171. "type": "group",
  172. "width": 17,
  173. "seriesGap": 3,
  174. "categoryGap": 5,
  175. "barBorderCircle": true,
  176. },
  177. "tooltip": tooltip,
  178. }
  179. },
  180. "area": {
  181. "type": "area",
  182. "animation": true,
  183. "timing": "easeOut",
  184. "duration": 500,
  185. "color": color,
  186. "padding": [
  187. 0, 10, 15, 5
  188. ],
  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": "#0052d4",
  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. "#0052d4",
  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. -10,
  538. -10,
  539. -10
  540. ],
  541. "dataLabel": false,
  542. "dataPointShape": false,
  543. "tapLegend": false,
  544. "xAxis": {
  545. "disabled": true,
  546. "axisLine": false,
  547. "disableGrid": true,
  548. },
  549. "yAxis": {
  550. "disabled": true,
  551. "disableGrid": true,
  552. "data": [{
  553. "min": 0,
  554. }]
  555. },
  556. "legend": {
  557. "show": false,
  558. },
  559. "extra": {
  560. "area": {
  561. "type": "curve",
  562. "opacity": 0.7,
  563. "addLine": true,
  564. "width": 2,
  565. "gradient": true
  566. },
  567. "tooltip": tooltip,
  568. }
  569. },
  570. }
  571. export default cfu;