charts.vue 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. <template>
  2. <view>
  3. <view class="charts-box">
  4. <qiun-data-charts
  5. @getIndex='getdata'
  6. type="column"
  7. :chartData="chartData"
  8. background="none"
  9. />
  10. </view>
  11. </view>
  12. </template>
  13. <script>
  14. export default {
  15. name: "buy",
  16. data() {
  17. return {
  18. chartData:{
  19.  categories:['2016','2017','2018','2019','2020','2021'],
  20.  series:[{
  21.   name:'目标值',
  22.   data:[35, 36, 31, 33, 13, 34]
  23.  },{
  24.   name:'完成量',
  25.   data:[18, 27, 21, 24, 6, 28]
  26.  }]
  27. }
  28. };
  29. },
  30. onShow() {
  31. new uCharts({
  32. $this:_self,
  33. canvasId: canvasId,
  34. type: 'line',
  35. fontSize:11,
  36. legend:{show:true},
  37. dataLabel:true,
  38. dataPointShape:true,
  39. background:'#FFFFFF',
  40. pixelRatio:_self.pixelRatio,
  41. categories: chartData.categories,
  42. series: chartData.series,
  43. animation: true,
  44. xAxis: {
  45. disabled:true,
  46. disableGrid:false,
  47. type:'grid',
  48. gridColor:'#CCCCCC',
  49. gridType:'dash',
  50. dashLength:8
  51. },
  52. yAxis: {
  53. gridType:'dash',
  54. gridColor:'#CCCCCC',
  55. dashLength:8,
  56. splitNumber:5,
  57. min:10,
  58. max:180,
  59. format:(val)=>{return val.toFixed(0)+'元'}
  60. },
  61. width: _self.cWidth*_self.pixelRatio,
  62. height: _self.cHeight*_self.pixelRatio,
  63. extra: {
  64. lineStyle: 'straight'
  65. }
  66. });
  67. },
  68. onLoad(options) {
  69. },
  70. onPageScroll(e) {
  71. this.scrollTop = e.scrollTop;
  72. },
  73. //下拉刷新
  74. onPullDownRefresh() {
  75. this.pages = 1
  76. this.isLoadMore = false
  77. this.loadStatus = 'loading'
  78. this.loadData()
  79. },
  80. onReachBottom(){ //上拉触底函数
  81. if(!this.isLoadMore){ //此处判断,上锁,防止重复请求
  82. this.isLoadMore=true
  83. this.pages += 1
  84. this.getIndexBuyData()
  85. }
  86. },
  87. methods: {
  88. getdata(){
  89. console.log(11111)
  90. }
  91. },
  92. }
  93. </script>
  94. <style>
  95. .charts-box{
  96. width: 100%;
  97. height:300px;
  98. }
  99. </style>