Commit f96e9363 authored by wends's avatar wends

fix g2line performance issue

parent 9ac6b3f2
<template>
<div :ref="id" style="height: 100%;width: 100%" />
<div :id="id" style="height: 100%;width: 100%" />
</template>
<script>
......@@ -32,13 +32,25 @@ export default {
}
},
watch: {
title: function(val) {
this.line.updateConfig({
title: {
visible: true,
text: val
},
description: {
visible: true,
text: `单位为: ${this.description}`
}
})
this.line.render()
},
lineData: function(val) {
this.line.changeData(val)
}
},
mounted() {
const el = this.$refs[this.id]
this.line = new Line(el, {
this.line = new Line(document.getElementById(this.id), {
data: this.lineData,
title: {
visible: true,
......@@ -57,7 +69,13 @@ export default {
crosshairs: {
type: 'y'
},
offset: 20
offset: 20,
formatter: (x, y) => {
return {
name: this.title,
value: `${y} ${this.description}`
}
}
},
description: {
visible: true,
......@@ -74,6 +92,9 @@ export default {
]
})
this.line.render()
},
beforeDestroy() {
this.line.destroy()
}
}
</script>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment