|
@@ -49,29 +49,38 @@ export default {
|
|
|
});
|
|
|
});
|
|
|
},
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ echartInstance:null
|
|
|
+ }
|
|
|
+ },
|
|
|
methods: {
|
|
|
_initEchart() {
|
|
|
let that=this
|
|
|
- const echartInstance = echarts.init(this.$refs.baseEchartRef);
|
|
|
- console.log(this.option)
|
|
|
- echartInstance.setOption(this.option);
|
|
|
- echartInstance.on('legendselectchanged', function (params) {
|
|
|
+ if(that.echartInstance==null){
|
|
|
+ that.echartInstance = echarts.init(this.$refs.baseEchartRef);
|
|
|
+ }
|
|
|
+ //console.log(this.option)
|
|
|
+ that.echartInstance.clear();
|
|
|
+ console.log(123123)
|
|
|
+ that.echartInstance.setOption(this.option,true);
|
|
|
+ that.echartInstance.on('legendselectchanged', function (params) {
|
|
|
if(that.option.name=='barOption'){
|
|
|
that.$emit('legendselectchanged',params.selected)
|
|
|
}
|
|
|
});
|
|
|
let echartTime=null
|
|
|
- echartInstance.on('highlight', (params) => {
|
|
|
+ that.echartInstance.on('highlight', (params) => {
|
|
|
echartTime = setInterval(() => {
|
|
|
- echartInstance.dispatchAction({
|
|
|
+ that.echartInstance.dispatchAction({
|
|
|
type: 'showTip',
|
|
|
seriesIndex: 0,
|
|
|
name: params.name,
|
|
|
});
|
|
|
}, 300)
|
|
|
})
|
|
|
- echartInstance.on('downplay', () => {
|
|
|
- echartInstance.dispatchAction({
|
|
|
+ that.echartInstance.on('downplay', () => {
|
|
|
+ that.echartInstance.dispatchAction({
|
|
|
type: 'hideTip'
|
|
|
})
|
|
|
clearInterval(echartTime);
|
|
@@ -79,7 +88,7 @@ export default {
|
|
|
if(that.option.showheigh){
|
|
|
let indexOfMax = 0;
|
|
|
let max = that.option.series[0].data.reduce( (a,c,i) => c.value > a ? (indexOfMax = i,c.value) : a, 0)
|
|
|
- echartInstance.dispatchAction({
|
|
|
+ that.echartInstance.dispatchAction({
|
|
|
type: 'highlight',
|
|
|
seriesIndex: 0,
|
|
|
dataIndex: indexOfMax
|