config-ucharts.js 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591
  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. "tooltipCustom":function(item, category, index, opts){
  55. return item.data
  56. }
  57. },
  58. //这里演示了自定义您的图表类型的option,可以随意命名,之后在组件上 type="demotype" 后,组件会调用这个花括号里的option,如果组件上还存在opts参数,会将demotype与opts中option合并后渲染图表。
  59. "demotype":{
  60. //我这里把曲线图当做了自定义图表类型,您可以根据需要随意指定类型或配置
  61. "type": "line",
  62. "color": color,
  63. "padding": [15,10,0,15],
  64. "xAxis": {
  65. "disableGrid": true,
  66. },
  67. "yAxis": {
  68. "gridType": "dash",
  69. "dashLength": 2,
  70. },
  71. "legend": {
  72. },
  73. "extra": {
  74. "line": {
  75. "type": "curve",
  76. "width": 2
  77. },
  78. }
  79. },
  80. //下面是自定义配置,请添加项目所需的通用配置
  81. "pie":{
  82. "type": "pie",
  83. "color": color,
  84. "padding": [5,5,5,5],
  85. "extra": {
  86. "pie": {
  87. "activeOpacity": 0.5,
  88. "activeRadius": 10,
  89. "offsetAngle": 0,
  90. "labelWidth": 15,
  91. "border": true,
  92. "borderWidth": 3,
  93. "borderColor": "#FFFFFF"
  94. },
  95. }
  96. },
  97. "ring":{
  98. "type": "ring",
  99. "color": color,
  100. "padding": [5,5,5,5],
  101. "rotate": false,
  102. "dataLabel": true,
  103. "legend": {
  104. "show": true,
  105. "position": "right",
  106. "lineHeight": 25,
  107. },
  108. "title": {
  109. "name": "收益率",
  110. "fontSize": 15,
  111. "color": "#666666"
  112. },
  113. "subtitle": {
  114. "name": "70%",
  115. "fontSize": 25,
  116. "color": "#7cb5ec"
  117. },
  118. "extra": {
  119. "ring": {
  120. "ringWidth":30,
  121. "activeOpacity": 0.5,
  122. "activeRadius": 10,
  123. "offsetAngle": 0,
  124. "labelWidth": 15,
  125. "border": true,
  126. "borderWidth": 3,
  127. "borderColor": "#FFFFFF"
  128. },
  129. },
  130. },
  131. "rose":{
  132. "type": "rose",
  133. "color": color,
  134. "padding": [5,5,5,5],
  135. "legend": {
  136. "show": true,
  137. "position": "left",
  138. "lineHeight": 25,
  139. },
  140. "extra": {
  141. "rose": {
  142. "type": "area",
  143. "minRadius": 50,
  144. "activeOpacity": 0.5,
  145. "activeRadius": 10,
  146. "offsetAngle": 0,
  147. "labelWidth": 15,
  148. "border": false,
  149. "borderWidth": 2,
  150. "borderColor": "#FFFFFF"
  151. },
  152. }
  153. },
  154. "word":{
  155. "type": "word",
  156. "color": color,
  157. "extra": {
  158. "word": {
  159. "type": "normal",
  160. "autoColors": false
  161. }
  162. }
  163. },
  164. "funnel":{
  165. "type": "funnel",
  166. "color": color,
  167. "padding": [15,15,0,15],
  168. "extra": {
  169. "funnel": {
  170. "activeOpacity": 0.3,
  171. "activeWidth": 10,
  172. "border": true,
  173. "borderWidth": 2,
  174. "borderColor": "#FFFFFF",
  175. "fillOpacity": 1,
  176. "labelAlign": "right"
  177. },
  178. }
  179. },
  180. "map":{
  181. "type": "map",
  182. "color": color,
  183. "padding": [0,0,0,0],
  184. "dataLabel": true,
  185. "extra": {
  186. "map": {
  187. "border": true,
  188. "borderWidth": 1,
  189. "borderColor": "#666666",
  190. "fillOpacity": 0.6,
  191. "activeBorderColor": "#F04864",
  192. "activeFillColor": "#FACC14",
  193. "activeFillOpacity": 1
  194. },
  195. }
  196. },
  197. "arcbar":{
  198. "type": "arcbar",
  199. "color": color,
  200. "title": {
  201. "name": "百分比",
  202. "fontSize": 25,
  203. "color": "#00FF00"
  204. },
  205. "subtitle": {
  206. "name": "默认标题",
  207. "fontSize": 15,
  208. "color": "#666666"
  209. },
  210. "extra": {
  211. "arcbar": {
  212. "type": "default",
  213. "width": 12,
  214. "backgroundColor": "#E9E9E9",
  215. "startAngle": 0.75,
  216. "endAngle": 0.25,
  217. "gap": 2
  218. }
  219. }
  220. },
  221. "line":{
  222. "type": "line",
  223. "color": color,
  224. "padding": [15,10,0,15],
  225. "xAxis": {
  226. "disableGrid": true,
  227. },
  228. "yAxis": {
  229. "gridType": "dash",
  230. "dashLength": 2,
  231. },
  232. "legend": {
  233. },
  234. "extra": {
  235. "line": {
  236. "type": "straight",
  237. "width": 2,
  238. "activeType": "hollow"
  239. },
  240. }
  241. },
  242. "tline":{
  243. "type": "line",
  244. "color": color,
  245. "padding": [15,10,0,15],
  246. "xAxis": {
  247. "disableGrid": false,
  248. "boundaryGap":"justify",
  249. },
  250. "yAxis": {
  251. "gridType": "dash",
  252. "dashLength": 2,
  253. "data":[
  254. {
  255. "min":0,
  256. "max":80
  257. }
  258. ]
  259. },
  260. "legend": {
  261. },
  262. "extra": {
  263. "line": {
  264. "type": "curve",
  265. "width": 2,
  266. "activeType": "hollow"
  267. },
  268. }
  269. },
  270. "tarea":{
  271. "type": "area",
  272. "color": color,
  273. "padding": [15,10,0,15],
  274. "xAxis": {
  275. "disableGrid": true,
  276. "boundaryGap":"justify",
  277. },
  278. "yAxis": {
  279. "gridType": "dash",
  280. "dashLength": 2,
  281. "data":[
  282. {
  283. "min":0,
  284. "max":80
  285. }
  286. ]
  287. },
  288. "legend": {
  289. },
  290. "extra": {
  291. "area": {
  292. "type": "curve",
  293. "opacity": 0.2,
  294. "addLine": true,
  295. "width": 2,
  296. "gradient": true,
  297. "activeType": "hollow"
  298. },
  299. }
  300. },
  301. "column":{
  302. "type": "column",
  303. "color": color,
  304. "padding": [15,15,0,5],
  305. "xAxis": {
  306. "disableGrid": true,
  307. },
  308. "yAxis": {
  309. "data":[{"min":0}]
  310. },
  311. "legend": {
  312. },
  313. "extra": {
  314. "column": {
  315. "type": "group",
  316. "width": 30,
  317. "activeBgColor": "#000000",
  318. "activeBgOpacity": 0.08
  319. },
  320. }
  321. },
  322. "mount":{
  323. "type": "mount",
  324. "color": color,
  325. "padding": [15,15,0,5],
  326. "xAxis": {
  327. "disableGrid": true,
  328. },
  329. "yAxis": {
  330. "data":[{"min":0}]
  331. },
  332. "legend": {
  333. },
  334. "extra": {
  335. "mount": {
  336. "type": "mount",
  337. "widthRatio": 1.5,
  338. },
  339. }
  340. },
  341. "bar":{
  342. "type": "bar",
  343. "color": color,
  344. "padding": [15,30,0,5],
  345. "xAxis": {
  346. "boundaryGap":"justify",
  347. "disableGrid":false,
  348. "min":0,
  349. "axisLine":false
  350. },
  351. "yAxis": {
  352. },
  353. "legend": {
  354. },
  355. "extra": {
  356. "bar": {
  357. "type": "group",
  358. "width": 30,
  359. "meterBorde": 1,
  360. "meterFillColor": "#FFFFFF",
  361. "activeBgColor": "#000000",
  362. "activeBgOpacity": 0.08
  363. },
  364. }
  365. },
  366. "area":{
  367. "type": "area",
  368. "color": color,
  369. "padding": [15,15,0,15],
  370. "xAxis": {
  371. "disableGrid": true,
  372. },
  373. "yAxis": {
  374. "gridType": "dash",
  375. "dashLength": 2,
  376. },
  377. "legend": {
  378. },
  379. "extra": {
  380. "area": {
  381. "type": "straight",
  382. "opacity": 0.2,
  383. "addLine": true,
  384. "width": 2,
  385. "gradient": false,
  386. "activeType": "hollow"
  387. },
  388. }
  389. },
  390. "radar":{
  391. "type": "radar",
  392. "color": color,
  393. "padding": [5,5,5,5],
  394. "dataLabel": false,
  395. "legend": {
  396. "show": true,
  397. "position": "right",
  398. "lineHeight": 25,
  399. },
  400. "extra": {
  401. "radar": {
  402. "gridType": "radar",
  403. "gridColor": "#CCCCCC",
  404. "gridCount": 3,
  405. "opacity": 0.2,
  406. "max": 200,
  407. "labelShow": true
  408. },
  409. }
  410. },
  411. "gauge":{
  412. "type": "gauge",
  413. "color": color,
  414. "title": {
  415. "name": "66Km/H",
  416. "fontSize": 25,
  417. "color": "#2fc25b",
  418. "offsetY": 50
  419. },
  420. "subtitle": {
  421. "name": "实时速度",
  422. "fontSize": 15,
  423. "color": "#1890ff",
  424. "offsetY": -50
  425. },
  426. "extra": {
  427. "gauge": {
  428. "type": "default",
  429. "width": 30,
  430. "labelColor": "#666666",
  431. "startAngle": 0.75,
  432. "endAngle": 0.25,
  433. "startNumber": 0,
  434. "endNumber": 100,
  435. "labelFormat": "",
  436. "splitLine": {
  437. "fixRadius": 0,
  438. "splitNumber": 10,
  439. "width": 30,
  440. "color": "#FFFFFF",
  441. "childNumber": 5,
  442. "childWidth": 12
  443. },
  444. "pointer": {
  445. "width": 24,
  446. "color": "auto"
  447. }
  448. }
  449. }
  450. },
  451. "candle":{
  452. "type": "candle",
  453. "color": color,
  454. "padding": [15,15,0,15],
  455. "enableScroll": true,
  456. "enableMarkLine": true,
  457. "dataLabel": false,
  458. "xAxis": {
  459. "labelCount": 4,
  460. "itemCount": 40,
  461. "disableGrid": true,
  462. "gridColor": "#CCCCCC",
  463. "gridType": "solid",
  464. "dashLength": 4,
  465. "scrollShow": true,
  466. "scrollAlign": "left",
  467. "scrollColor": "#A6A6A6",
  468. "scrollBackgroundColor": "#EFEBEF"
  469. },
  470. "yAxis": {
  471. },
  472. "legend": {
  473. },
  474. "extra": {
  475. "candle": {
  476. "color": {
  477. "upLine": "#f04864",
  478. "upFill": "#f04864",
  479. "downLine": "#2fc25b",
  480. "downFill": "#2fc25b"
  481. },
  482. "average": {
  483. "show": true,
  484. "name": ["MA5","MA10","MA30"],
  485. "day": [5,10,20],
  486. "color": ["#1890ff","#2fc25b","#facc14"]
  487. }
  488. },
  489. "markLine": {
  490. "type": "dash",
  491. "dashLength": 5,
  492. "data": [
  493. {
  494. "value": 2150,
  495. "lineColor": "#f04864",
  496. "showLabel": true
  497. },
  498. {
  499. "value": 2350,
  500. "lineColor": "#f04864",
  501. "showLabel": true
  502. }
  503. ]
  504. }
  505. }
  506. },
  507. "mix":{
  508. "type": "mix",
  509. "color": color,
  510. "padding": [15,15,0,15],
  511. "xAxis": {
  512. "disableGrid": true,
  513. },
  514. "yAxis": {
  515. "disabled": false,
  516. "disableGrid": false,
  517. "splitNumber": 5,
  518. "gridType": "dash",
  519. "dashLength": 4,
  520. "gridColor": "#CCCCCC",
  521. "padding": 10,
  522. "showTitle": true,
  523. "data": []
  524. },
  525. "legend": {
  526. },
  527. "extra": {
  528. "mix": {
  529. "column": {
  530. "width": 20
  531. }
  532. },
  533. }
  534. },
  535. "scatter":{
  536. "type": "scatter",
  537. "color":color,
  538. "padding":[15,15,0,15],
  539. "dataLabel":false,
  540. "xAxis": {
  541. "disableGrid": false,
  542. "gridType":"dash",
  543. "splitNumber":5,
  544. "boundaryGap":"justify",
  545. "min":0
  546. },
  547. "yAxis": {
  548. "disableGrid": false,
  549. "gridType":"dash",
  550. },
  551. "legend": {
  552. },
  553. "extra": {
  554. "scatter": {
  555. },
  556. }
  557. },
  558. "bubble":{
  559. "type": "bubble",
  560. "color":color,
  561. "padding":[15,15,0,15],
  562. "xAxis": {
  563. "disableGrid": false,
  564. "gridType":"dash",
  565. "splitNumber":5,
  566. "boundaryGap":"justify",
  567. "min":0,
  568. "max":250
  569. },
  570. "yAxis": {
  571. "disableGrid": false,
  572. "gridType":"dash",
  573. "data":[{
  574. "min":0,
  575. "max":150
  576. }]
  577. },
  578. "legend": {
  579. },
  580. "extra": {
  581. "bubble": {
  582. "border":2,
  583. "opacity": 0.5,
  584. },
  585. }
  586. }
  587. }
  588. export default cfu;