config-ucharts.js 17 KB

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