config-ucharts.js 16 KB

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