echart重绘 数据更新 但是legend却没有更新

{
    let studyConditionChart=echarts.init(document.getElementById('studyCondition'));
        studyConditionChart.setOption(this.OptionStudyCondition,true);
        //注意这里一定要有参数true
}

在使用echart时,数据会动态加载,在不同情形之下,数据不同。更换数据以及在legend栏,设置了动态的数据,如下所示,

 dataset: {
                    //提供一份数据
                    source:this.studyConditionDataSet,
                },
                legend:{
                    itemHeight:6,//图例的高度
                    itemGap:20,//图例间距
                    itemWidth:10,//图例的宽度
                    textStyle:{//整体设置文字部分的样式
                                color:'#666',
                                fontSize:12,
                                fontweight:400,
                                height:16.5,
                                lineHeight:16.5,
                                padding:[0,30,0,0],
                                },
                    data:[this.studyConditionDataSet[0][1],this.studyConditionDataSet[0][2]]
                },

如果只设置这些,是不能达到legend以及视图也随之变化的,需要在setOption时,加参数true!!! 这样设置之后,就每次都会全部重绘了。

这篇文章解释了同一问题,https://blog.csdn.net/console__/article/details/80907639

猜你喜欢

转载自blog.csdn.net/mia1106/article/details/83540746