g2plot 水滴图,包含数据更新时渲染问题

2023-11-02

官网地址:https://g2plot.antv.vision/zh/docs/manual/introduction

 

第一步: vue安装对应插件(网上很多,可以百度一下)

npm install @antv/g2plot --save

第二步:引入

import { Liquid } from '@antv/g2plot'

创建对应的div

<div id="linechart" />

data定义一个 linePlot

加载

mounted() {

  var v = this

  this.$nextTick(() => {

    v.drawChart()

  })

},

在methods里面加载方法:

drawChart() {

this.linePlot = new Liquid('linechart', {

   percent: 0.88,

    width: 120,

    height: 120,

    outline: {

     border: 2,

      distance: 2

    },

    wave: {

      length: 128

    },

    statistic: {

      content: {

      style: ({ percent }) => ({

        fontSize: 20,

        lineHeight: 1,

        fill: percent > 0.65 ? 'white' : 'rgba(44,53,66,0.85)'

      })

     }

    }

   })

   this.linePlot.render()

}

数据更新时,调用此方案

changeEchart() {

  if (this.linePlot) {

    this.linePlot.chart.changeData(0.66)

  } else {

    this.drawChart()

  }

},

第一次整理 有问题请见谅

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

g2plot 水滴图,包含数据更新时渲染问题 的相关文章

  • 货舱容量分配问题

    4 选做 一架货机有三个货舱 前舱 中舱和后舱 三个货舱所能装载的 货物的最大重量和体积有限制 如表 3 所示 现有四类货物用该货机进行装运 货物的规格以及装运后获得的利润如表 4 所示 并且为了飞机的平衡 三个货 舱装载的货物重量必须与其
  • 最近读了《软件调试的艺术》这本书

    最近读了 软件调试的艺术 这本书 英文名

随机推荐