config-ucharts.js 12 KB

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