Last active
December 9, 2016 08:20
-
-
Save erguotou520/32f82d5b32317dd2f3076277538f2681 to your computer and use it in GitHub Desktop.
EchartBar.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<div class="ui-echart ui-echart-bar" ref="chart"></div> | |
</template> | |
<script> | |
import echarts from 'echarts/lib/echarts' | |
import 'echarts/lib/chart/bar' | |
import 'echarts/lib/chart/line' | |
import 'echarts/lib/component/title' | |
import 'echarts/lib/component/tooltip' | |
export default { | |
props: { | |
option: { | |
required: true | |
}, | |
loading: Boolean | |
}, | |
data () { | |
return { | |
echart: null | |
} | |
}, | |
watch: { | |
option: { | |
deep: true, | |
handler (val) { | |
if (val) { | |
// draw chart | |
this.echart.setOption(val) | |
} | |
} | |
}, | |
loading (val) { | |
if (val) { | |
this.echart.clear() | |
// this.echart && this.echart.showLoading() | |
} else { | |
// this.echart && this.echart.hideLoading() | |
} | |
} | |
}, | |
mounted () { | |
this.$nextTick(() => { | |
// init echart instance | |
this.echart = echarts.init(this.$refs.chart) | |
this.echart.setOption(this.option) | |
}) | |
} | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment