美文网首页
微信小程序解决echarts图表不清晰的问题

微信小程序解决echarts图表不清晰的问题

作者: ERROR505 | 来源:发表于2021-12-20 21:52 被阅读0次

原文链接:https://blog.csdn.net/weixin_43985637/article/details/105242537

1.获取设备的像素

 const getPixelRatio = () => {
        let pixelRatio = 0
        wx.getSystemInfo({
          success: function (res) {
            pixelRatio = res.pixelRatio
          },
          fail: function () {
            pixelRatio = 0
          }
        })
        return pixelRatio
      }

2.初始化图表的时候设置像素比

devicePixelRatio

     //获取像素比
      const getPixelRatio = () => {
        let pixelRatio = 0
        wx.getSystemInfo({
          success: function (res) {
            pixelRatio = res.pixelRatio
          },
          fail: function () {
            pixelRatio = 0
          }
        })
        return pixelRatio
      }
      // console.log(pixelRatio)
      var dpr = getPixelRatio()
        // 初始化图表
      const chart = echarts.init(canvas, null, {
        // renderer: 'svg',//微信小程序中不支持该设置
        width: width,
        height: height,
        devicePixelRatio: dpr
      });
      setOption(chart,this);


相关文章

网友评论

      本文标题:微信小程序解决echarts图表不清晰的问题

      本文链接:https://www.haomeiwen.com/subject/qgduoltx.html