config-ucharts.js 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588
  1. // 主题颜色配置:如每个图表类型需要不同主题,请在对应图表类型上更改color属性
  2. const color = ['#1890FF', '#91CB74', '#FAC858', '#EE6666', '#73C0DE', '#3CA272', '#FC8452', '#9A60B4', '#ea7ccc'];
  3. //事件转换函数,主要用作格式化x轴为时间轴,根据需求自行修改
  4. const formatDateTime = (timeStamp, returnType)=>{
  5. var date = new Date();
  6. date.setTime(timeStamp * 1000);
  7. var y = date.getFullYear();
  8. var m = date.getMonth() + 1;
  9. m = m < 10 ? ('0' + m) : m;
  10. var d = date.getDate();
  11. d = d < 10 ? ('0' + d) : d;
  12. var h = date.getHours();
  13. h = h < 10 ? ('0' + h) : h;
  14. var minute = date.getMinutes();
  15. var second = date.getSeconds();
  16. minute = minute < 10 ? ('0' + minute) : minute;
  17. second = second < 10 ? ('0' + second) : second;
  18. if(returnType == 'full'){return y + '-' + m + '-' + d + ' '+ h +':' + minute + ':' + second;}
  19. if(returnType == 'y-m-d'){return y + '-' + m + '-' + d;}
  20. if(returnType == 'h:m'){return h +':' + minute;}
  21. if(returnType == 'h:m:s'){return h +':' + minute +':' + second;}
  22. return [y, m, d, h, minute, second];
  23. }
  24. const cfu = {
  25. //demotype为自定义图表类型,一般不需要自定义图表类型,只需要改根节点上对应的类型即可
  26. "type":["pie","ring","rose","word","funnel","map","arcbar","line","column","mount","bar","area","radar","gauge","candle","mix","tline","tarea","scatter","bubble","demotype"],
  27. "range":["饼状图","圆环图","玫瑰图","词云图","漏斗图","地图","圆弧进度条","折线图","柱状图","山峰图","条状图","区域图","雷达图","仪表盘","K线图","混合图","时间轴折线","时间轴区域","散点图","气泡图","自定义类型"],
  28. //增加自定义图表类型,如果需要categories,请在这里加入您的图表类型,例如最后的"demotype"
  29. //自定义类型时需要注意"tline","tarea","scatter","bubble"等时间轴(矢量x轴)类图表,没有categories,不需要加入categories
  30. "categories":["line","column","mount","bar","area","radar","gauge","candle","mix","demotype"],
  31. //instance为实例变量承载属性,不要删除
  32. "instance":{},
  33. //option为opts及eopts承载属性,不要删除
  34. "option":{},
  35. //下面是自定义format配置,因除H5端外的其他端无法通过props传递函数,只能通过此属性对应下标的方式来替换
  36. "formatter":{
  37. "yAxisDemo1":function(val, index, opts){return val+'元'},
  38. "yAxisDemo2":function(val, index, opts){return val.toFixed(2)},
  39. "xAxisDemo1":function(val, index, opts){return val+'年';},
  40. "xAxisDemo2":function(val, index, opts){return formatDateTime(val,'h:m')},
  41. "seriesDemo1":function(val, index, series, opts){return val+'元'},
  42. "tooltipDemo1":function(item, category, index, opts){
  43. if(index==0){
  44. return '随便用'+item.data+'年'
  45. }else{
  46. return '其他我没改'+item.data+'天'
  47. }
  48. },
  49. "pieDemo":function(val, index, series, opts){
  50. if(index !== undefined){
  51. return series[index].name+':'+series[index].data+'元'
  52. }
  53. },
  54. },
  55. //这里演示了自定义您的图表类型的option,可以随意命名,之后在组件上 type="demotype" 后,组件会调用这个花括号里的option,如果组件上还存在opts参数,会将demotype与opts中option合并后渲染图表。
  56. "demotype":{
  57. //我这里把曲线图当做了自定义图表类型,您可以根据需要随意指定类型或配置
  58. "type": "line",
  59. "color": color,
  60. "padding": [15,10,0,15],
  61. "xAxis": {
  62. "disableGrid": true,
  63. },
  64. "yAxis": {
  65. "gridType": "dash",
  66. "dashLength": 2,
  67. },
  68. "legend": {
  69. },
  70. "extra": {
  71. "line": {
  72. "type": "curve",
  73. "width": 2
  74. },
  75. }
  76. },
  77. //下面是自定义配置,请添加项目所需的通用配置
  78. "pie":{
  79. "type": "pie",
  80. "color": color,
  81. "padding": [5,5,5,5],
  82. "extra": {
  83. "pie": {
  84. "activeOpacity": 0.5,
  85. "activeRadius": 10,
  86. "offsetAngle": 0,
  87. "labelWidth": 15,
  88. "border": true,
  89. "borderWidth": 3,
  90. "borderColor": "#FFFFFF"
  91. },
  92. }
  93. },
  94. "ring":{
  95. "type": "ring",
  96. "color": color,
  97. "padding": [5,5,5,5],
  98. "rotate": false,
  99. "dataLabel": true,
  100. "legend": {
  101. "show": true,
  102. "position": "right",
  103. "lineHeight": 25,
  104. },
  105. "title": {
  106. "name": "收益率",
  107. "fontSize": 15,
  108. "color": "#666666"
  109. },
  110. "subtitle": {
  111. "name": "70%",
  112. "fontSize": 25,
  113. "color": "#7cb5ec"
  114. },
  115. "extra": {
  116. "ring": {
  117. "ringWidth":30,
  118. "activeOpacity": 0.5,
  119. "activeRadius": 10,
  120. "offsetAngle": 0,
  121. "labelWidth": 15,
  122. "border": true,
  123. "borderWidth": 3,
  124. "borderColor": "#FFFFFF"
  125. },
  126. },
  127. },
  128. "rose":{
  129. "type": "rose",
  130. "color": color,
  131. "padding": [5,5,5,5],
  132. "legend": {
  133. "show": true,
  134. "position": "left",
  135. "lineHeight": 25,
  136. },
  137. "extra": {
  138. "rose": {
  139. "type": "area",
  140. "minRadius": 50,
  141. "activeOpacity": 0.5,
  142. "activeRadius": 10,
  143. "offsetAngle": 0,
  144. "labelWidth": 15,
  145. "border": false,
  146. "borderWidth": 2,
  147. "borderColor": "#FFFFFF"
  148. },
  149. }
  150. },
  151. "word":{
  152. "type": "word",
  153. "color": color,
  154. "extra": {
  155. "word": {
  156. "type": "normal",
  157. "autoColors": false
  158. }
  159. }
  160. },
  161. "funnel":{
  162. "type": "funnel",
  163. "color": color,
  164. "padding": [15,15,0,15],
  165. "extra": {
  166. "funnel": {
  167. "activeOpacity": 0.3,
  168. "activeWidth": 10,
  169. "border": true,
  170. "borderWidth": 2,
  171. "borderColor": "#FFFFFF",
  172. "fillOpacity": 1,
  173. "labelAlign": "right"
  174. },
  175. }
  176. },
  177. "map":{
  178. "type": "map",
  179. "color": color,
  180. "padding": [0,0,0,0],
  181. "dataLabel": true,
  182. "extra": {
  183. "map": {
  184. "border": true,
  185. "borderWidth": 1,
  186. "borderColor": "#666666",
  187. "fillOpacity": 0.6,
  188. "activeBorderColor": "#F04864",
  189. "activeFillColor": "#FACC14",
  190. "activeFillOpacity": 1
  191. },
  192. }
  193. },
  194. "arcbar":{
  195. "type": "arcbar",
  196. "color": color,
  197. "title": {
  198. "name": "百分比",
  199. "fontSize": 25,
  200. "color": "#00FF00"
  201. },
  202. "subtitle": {
  203. "name": "默认标题",
  204. "fontSize": 15,
  205. "color": "#666666"
  206. },
  207. "extra": {
  208. "arcbar": {
  209. "type": "default",
  210. "width": 12,
  211. "backgroundColor": "#E9E9E9",
  212. "startAngle": 0.75,
  213. "endAngle": 0.25,
  214. "gap": 2
  215. }
  216. }
  217. },
  218. "line":{
  219. "type": "line",
  220. "color": color,
  221. "padding": [15,10,0,15],
  222. "xAxis": {
  223. "disableGrid": true,
  224. },
  225. "yAxis": {
  226. "gridType": "dash",
  227. "dashLength": 2,
  228. },
  229. "legend": {
  230. },
  231. "extra": {
  232. "line": {
  233. "type": "straight",
  234. "width": 2,
  235. "activeType": "hollow"
  236. },
  237. }
  238. },
  239. "tline":{
  240. "type": "line",
  241. "color": color,
  242. "padding": [15,10,0,15],
  243. "xAxis": {
  244. "disableGrid": false,
  245. "boundaryGap":"justify",
  246. },
  247. "yAxis": {
  248. "gridType": "dash",
  249. "dashLength": 2,
  250. "data":[
  251. {
  252. "min":0,
  253. "max":80
  254. }
  255. ]
  256. },
  257. "legend": {
  258. },
  259. "extra": {
  260. "line": {
  261. "type": "curve",
  262. "width": 2,
  263. "activeType": "hollow"
  264. },
  265. }
  266. },
  267. "tarea":{
  268. "type": "area",
  269. "color": color,
  270. "padding": [15,10,0,15],
  271. "xAxis": {
  272. "disableGrid": true,
  273. "boundaryGap":"justify",
  274. },
  275. "yAxis": {
  276. "gridType": "dash",
  277. "dashLength": 2,
  278. "data":[
  279. {
  280. "min":0,
  281. "max":80
  282. }
  283. ]
  284. },
  285. "legend": {
  286. },
  287. "extra": {
  288. "area": {
  289. "type": "curve",
  290. "opacity": 0.2,
  291. "addLine": true,
  292. "width": 2,
  293. "gradient": true,
  294. "activeType": "hollow"
  295. },
  296. }
  297. },
  298. "column":{
  299. "type": "column",
  300. "color": color,
  301. "padding": [15,15,0,5],
  302. "xAxis": {
  303. "disableGrid": true,
  304. },
  305. "yAxis": {
  306. "data":[{"min":0}]
  307. },
  308. "legend": {
  309. },
  310. "extra": {
  311. "column": {
  312. "type": "group",
  313. "width": 30,
  314. "activeBgColor": "#000000",
  315. "activeBgOpacity": 0.08
  316. },
  317. }
  318. },
  319. "mount":{
  320. "type": "mount",
  321. "color": color,
  322. "padding": [15,15,0,5],
  323. "xAxis": {
  324. "disableGrid": true,
  325. },
  326. "yAxis": {
  327. "data":[{"min":0}]
  328. },
  329. "legend": {
  330. },
  331. "extra": {
  332. "mount": {
  333. "type": "mount",
  334. "widthRatio": 1.5,
  335. },
  336. }
  337. },
  338. "bar":{
  339. "type": "bar",
  340. "color": color,
  341. "padding": [15,30,0,5],
  342. "xAxis": {
  343. "boundaryGap":"justify",
  344. "disableGrid":false,
  345. "min":0,
  346. "axisLine":false
  347. },
  348. "yAxis": {
  349. },
  350. "legend": {
  351. },
  352. "extra": {
  353. "bar": {
  354. "type": "group",
  355. "width": 30,
  356. "meterBorde": 1,
  357. "meterFillColor": "#FFFFFF",
  358. "activeBgColor": "#000000",
  359. "activeBgOpacity": 0.08
  360. },
  361. }
  362. },
  363. "area":{
  364. "type": "area",
  365. "color": color,
  366. "padding": [15,15,0,15],
  367. "xAxis": {
  368. "disableGrid": true,
  369. },
  370. "yAxis": {
  371. "gridType": "dash",
  372. "dashLength": 2,
  373. },
  374. "legend": {
  375. },
  376. "extra": {
  377. "area": {
  378. "type": "straight",
  379. "opacity": 0.2,
  380. "addLine": true,
  381. "width": 2,
  382. "gradient": false,
  383. "activeType": "hollow"
  384. },
  385. }
  386. },
  387. "radar":{
  388. "type": "radar",
  389. "color": color,
  390. "padding": [5,5,5,5],
  391. "dataLabel": false,
  392. "legend": {
  393. "show": true,
  394. "position": "right",
  395. "lineHeight": 25,
  396. },
  397. "extra": {
  398. "radar": {
  399. "gridType": "radar",
  400. "gridColor": "#CCCCCC",
  401. "gridCount": 3,
  402. "opacity": 0.2,
  403. "max": 200,
  404. "labelShow": true
  405. },
  406. }
  407. },
  408. "gauge":{
  409. "type": "gauge",
  410. "color": color,
  411. "title": {
  412. "name": "66Km/H",
  413. "fontSize": 25,
  414. "color": "#2fc25b",
  415. "offsetY": 50
  416. },
  417. "subtitle": {
  418. "name": "实时速度",
  419. "fontSize": 15,
  420. "color": "#1890ff",
  421. "offsetY": -50
  422. },
  423. "extra": {
  424. "gauge": {
  425. "type": "default",
  426. "width": 30,
  427. "labelColor": "#666666",
  428. "startAngle": 0.75,
  429. "endAngle": 0.25,
  430. "startNumber": 0,
  431. "endNumber": 100,
  432. "labelFormat": "",
  433. "splitLine": {
  434. "fixRadius": 0,
  435. "splitNumber": 10,
  436. "width": 30,
  437. "color": "#FFFFFF",
  438. "childNumber": 5,
  439. "childWidth": 12
  440. },
  441. "pointer": {
  442. "width": 24,
  443. "color": "auto"
  444. }
  445. }
  446. }
  447. },
  448. "candle":{
  449. "type": "candle",
  450. "color": color,
  451. "padding": [15,15,0,15],
  452. "enableScroll": true,
  453. "enableMarkLine": true,
  454. "dataLabel": false,
  455. "xAxis": {
  456. "labelCount": 4,
  457. "itemCount": 40,
  458. "disableGrid": true,
  459. "gridColor": "#CCCCCC",
  460. "gridType": "solid",
  461. "dashLength": 4,
  462. "scrollShow": true,
  463. "scrollAlign": "left",
  464. "scrollColor": "#A6A6A6",
  465. "scrollBackgroundColor": "#EFEBEF"
  466. },
  467. "yAxis": {
  468. },
  469. "legend": {
  470. },
  471. "extra": {
  472. "candle": {
  473. "color": {
  474. "upLine": "#f04864",
  475. "upFill": "#f04864",
  476. "downLine": "#2fc25b",
  477. "downFill": "#2fc25b"
  478. },
  479. "average": {
  480. "show": true,
  481. "name": ["MA5","MA10","MA30"],
  482. "day": [5,10,20],
  483. "color": ["#1890ff","#2fc25b","#facc14"]
  484. }
  485. },
  486. "markLine": {
  487. "type": "dash",
  488. "dashLength": 5,
  489. "data": [
  490. {
  491. "value": 2150,
  492. "lineColor": "#f04864",
  493. "showLabel": true
  494. },
  495. {
  496. "value": 2350,
  497. "lineColor": "#f04864",
  498. "showLabel": true
  499. }
  500. ]
  501. }
  502. }
  503. },
  504. "mix":{
  505. "type": "mix",
  506. "color": color,
  507. "padding": [15,15,0,15],
  508. "xAxis": {
  509. "disableGrid": true,
  510. },
  511. "yAxis": {
  512. "disabled": false,
  513. "disableGrid": false,
  514. "splitNumber": 5,
  515. "gridType": "dash",
  516. "dashLength": 4,
  517. "gridColor": "#CCCCCC",
  518. "padding": 10,
  519. "showTitle": true,
  520. "data": []
  521. },
  522. "legend": {
  523. },
  524. "extra": {
  525. "mix": {
  526. "column": {
  527. "width": 20
  528. }
  529. },
  530. }
  531. },
  532. "scatter":{
  533. "type": "scatter",
  534. "color":color,
  535. "padding":[15,15,0,15],
  536. "dataLabel":false,
  537. "xAxis": {
  538. "disableGrid": false,
  539. "gridType":"dash",
  540. "splitNumber":5,
  541. "boundaryGap":"justify",
  542. "min":0
  543. },
  544. "yAxis": {
  545. "disableGrid": false,
  546. "gridType":"dash",
  547. },
  548. "legend": {
  549. },
  550. "extra": {
  551. "scatter": {
  552. },
  553. }
  554. },
  555. "bubble":{
  556. "type": "bubble",
  557. "color":color,
  558. "padding":[15,15,0,15],
  559. "xAxis": {
  560. "disableGrid": false,
  561. "gridType":"dash",
  562. "splitNumber":5,
  563. "boundaryGap":"justify",
  564. "min":0,
  565. "max":250
  566. },
  567. "yAxis": {
  568. "disableGrid": false,
  569. "gridType":"dash",
  570. "data":[{
  571. "min":0,
  572. "max":150
  573. }]
  574. },
  575. "legend": {
  576. },
  577. "extra": {
  578. "bubble": {
  579. "border":2,
  580. "opacity": 0.5,
  581. },
  582. }
  583. }
  584. }
  585. export default cfu;