antv/g2

if (this.MQJZDSMS.length < 7) {
  for (let i = 0; i < 7 - this.MQJZDSMS.length; i++) {
    this.MQJZDSMS.push({EmployeeName: '', BomQty: ''})
  }
}
const data = this.MQJZDSMS
const chart = new G2.Chart({
  container: 'container',
  autoFit: true
})
chart.data(data)
var margin = 1 / data.length
var num = data[0].BomQty
for (let i = 0; i < data.length; i++) {
  if (data[i].BomQty > num) {
    num = data[i].BomQty
  }
}
chart.scale({
  BomQty: {
    min: 0,
    max: num + 500,
    nice: true
  },
  EmployeeName: {
    range: [0.02, 1 - margin / 2]
  }
})
chart.tooltip({
  showCrosshairs: true,
  shared: true
})

chart.axis('EmployeeName', false)
chart.axis('BomQty', {
  tickLine: {
    length: 6
  }
})
data.forEach((item) => {
  chart.annotation().text({
    position: [item.EmployeeName, item.BomQty],
    content: item.BomQty,
    style: {
      fill: '#06b2d0',
      textAlign: 'center'
    },
    offsetY: -10
  })
})
chart.line().position('EmployeeName*BomQty').color('#4ff3f5')
chart.area().position('EmployeeName*BomQty').color('l(30) 0:#4ff3f5 1:#189da6')
chart.point().position('EmployeeName*BomQty')
chart.render()

因为这个数据是实时刷新的,这个怎么重新渲染啊

阅读 1.9k
2 个回答
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题