微信小程序 自定义弹窗展示图表组件(echarts/AntV-f6)

15,264次阅读
没有评论

共计 1695 个字符,预计需要花费 5 分钟才能阅读完成。

小程序弹窗展示图表组件,可滑动放大等,弹窗操作不穿透底层

引用组件步骤:步骤

微信小程序 自定义弹窗展示图表组件(echarts/AntV-f6)

图表组件生成需要画面加载出载体 Dom,画面数据加载完毕后再隐藏,根据业务需求弹窗出现,防止穿透底层添加了 定位 fixed

view style="top:{{showTree?currentTop+'px':''}}"  class="{{showTree?'noscroll':''}}">
	label class="message" bindtap="setTreeData" data-treedata="{{item.resourceUrl}}" data-id="{{index}}" >{{item.name}}label>
view>

view wx:if="{{showTree}}">
   view class="pop-mask" wx:if="{{showPop}}">view>
   view class="pop-back" wx:if="{{showPop}}">view>
   button bindtap="dispose" wx:if="{{showPop}}" class="pop-btn"> 关闭 button>
   f6-canvas
     width="{{canvasWidth}}"
     height="{{canvasHeight}}"
     pixelRatio="{{pixelRatio}}"
     bind:onInit="handleCanvasInit"
     bind:onTouchEvent="handleTouch"
   />
 view>
  
  getData(){
	this.setData({
       showTree:false
     })
  }
  
  setTreeData(e){
    let id = e.target.dataset.id;
    let that = this;
    
    wx.createSelectorQuery().select('#item'+id).boundingClientRect(function(rect){
      that.setData({
        currentTop:rect.top
      })
    }).exec()
    let treedata = JSON.parse(e.target.dataset.treedata)
    this.setData({
      showTree:true,
      showPop:true,
    })
    let _this = this
    setTimeout(function(){
      
      _this.graph.data(treedata);
      _this.graph.render();
      _this.graph.fitView();
    },300)
  },
  
  dispose(){
    this.setData({
      showTree:false,
      showPop:false
    })
    wx.pageScrollTo({ scrollTop: -(this.data.currentTop-50),duration:0})
  },

.noscroll {
  
  overflow: hidden;
  position: fixed;
  z-index: 0;
  bottom: 0;
}
.pop-btn{
  position: fixed;
  bottom: 107px;
  left: 10px;
  right: 10px;
  z-index: 9999;
  margin: 0 !important;
}
.pop-mask{
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  background-color: #00000033;
  z-index: 9999;
}
.pop-back{
  background-color: #fff;
  height: 73vh;
  position: fixed;
  
  bottom: 107px;
  left: 10px;
  right: 10px;
  border-radius: 10px;
  z-index: 9999;
}
f6-canvas{
  height: 66vh;
  position: fixed;
  bottom: 165px;
  left: 10px;
  right: 10px;
  z-index: 999999999;
  overflow: hidden;
}

原文地址: 微信小程序 自定义弹窗展示图表组件(echarts/AntV-f6)

    正文完
     0
    Yojack
    版权声明:本篇文章由 Yojack 于2024-09-26发表,共计1695字。
    转载说明:
    1 本网站名称:优杰开发笔记
    2 本站永久网址:https://yojack.cn
    3 本网站的文章部分内容可能来源于网络,仅供大家学习与参考,如有侵权,请联系站长进行删除处理。
    4 本站一切资源不代表本站立场,并不代表本站赞同其观点和对其真实性负责。
    5 本站所有内容均可转载及分享, 但请注明出处
    6 我们始终尊重原创作者的版权,所有文章在发布时,均尽可能注明出处与作者。
    7 站长邮箱:laylwenl@gmail.com
    评论(没有评论)