Home > Article > Web Front-end > Introduction to vue antV G2-3.X componentization
This article mainly introduces the componentization of vue antV G2-3. I think the Alibaba chart antv is very good, and I want to integrate it into vue for use. Referring to Vuejs2.
npm install @antv/g2 --save
Modify HelloWorld.vue reference component
<template>
<p :id="id"></p>
</template>
<script>
import G2 from '@antv/g2'
export default {
data () {
return {
chart: null
}
},
props: {
charData: {
type: Array,
default: function () {
return {
data: []
}
}
},
id: String
},
mounted () {
this.drawChart()
},
methods: {
drawChart: function () {
this.chart && this.chart.destory()
this.chart = new G2.Chart({
container: this.id,
width: 600,
height: 300
})
this.chart.source(this.charData)
this.chart.scale('value', {
min: 0
})
this.chart.scale('year', {
range: [0, 1]
})
this.chart.tooltip({
crosshairs: {
type: 'line'
}
})
this.chart.line().position('year*value')
this.chart.point().position('year*value').size(4).shape('circle').style({
stroke: '#fff',
lineWidth: 1
})
this.chart.render()
}
}
}
</script> Effect
The above is the entire article Content, I hope it will be helpful to everyone’s learning. For more related content, please pay attention to the PHP Chinese website! Related recommendations:
How to add a dynamic browser header title to the Vue project

The above is the detailed content of Introduction to vue antV G2-3.X componentization. For more information, please follow other related articles on the PHP Chinese website!