Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

请问一个柱状图叠加数据刷新问题 #6715

Closed
GunhouWong opened this issue Sep 19, 2017 · 2 comments
Closed

请问一个柱状图叠加数据刷新问题 #6715

GunhouWong opened this issue Sep 19, 2017 · 2 comments
Labels
stale Inactive for a long time. Will be closed in 7 days.

Comments

@GunhouWong
Copy link

One-line summary [问题简述]

代码如下,加载第一个配置项时,只有一条柱,然后加载两条柱的第二个配置,然后再切换回第一个,但是图形没有还原到第一个。后来尝试了一下clear函数才能正常加载第一个数据。

问题是:配置项的设置不是完全覆盖上一次的设置的吗?为什么其他饼图之类的没有这种问题?导致的原因是什么?

Version & Environment [版本及环境]

  • ECharts version [ECharts 版本]:3.7.1
  • Browser version [浏览器类型和版本]: Chrome 61
  • OS Version [操作系统类型和版本]: Win 10 64bit

Expected behaviour [期望结果]

数据是否应该完全覆盖才对?

ECharts option [ECharts配置项]

    var myChart = echarts.init(document.getElementById("YP"));
	var option1 = {
	    tooltip : {
	        trigger: 'axis',
	        axisPointer : {            // 坐标轴指示器,坐标轴触发有效
	            type : 'shadow'        // 默认为直线,可选为:'line' | 'shadow'
	        }
	    },
	    legend: {
	        data:['废水','地表水']
	    },
	    grid: {
	        left: '3%',
	        right: '4%',
	        bottom: '3%',
	        containLabel: true
	    },
	    xAxis : [
	        {
	            type : 'category',
	            data : ['test']
	        }
	    ],
	    yAxis : [
	        {
	            type : 'value'
	        }
	    ],
	    series : [{
            name: '废水',
            type: 'bar',
            stack: 'two',
            data: [2]
        },{
            name: '地表水',
            type: 'bar',
            stack: 'two',
            data: [1]
        }]
	};
	
	var option2 = {
		    tooltip : {
		        trigger: 'axis',
		        axisPointer : {            // 坐标轴指示器,坐标轴触发有效
		            type : 'shadow'        // 默认为直线,可选为:'line' | 'shadow'
		        }
		    },
		    legend: {
		        data:['废气']
		    },
		    grid: {
		        left: '3%',
		        right: '4%',
		        bottom: '3%',
		        containLabel: true
		    },
		    xAxis : [
		        {
		            type : 'category',
		            data : ['test']
		        }
		    ],
		    yAxis : [
		        {
		            type : 'value'
		        }
		    ],
		    series : [{
	            name: '废气',
	            type: 'bar',
	            stack: 'two',
	            data: [1]
	        }]
		};
	
	// 使用刚指定的配置项和数据显示图表。
	var aa = true;
	setInterval(function() {
        //后面找了一下文档调用clear后解决。
        //myChart.clear();
		myChart.setOption((aa = !aa) ? option1 : option2);
	}, 2000);
    

Other comments [其他信息]

@Ovilia
Copy link
Contributor

Ovilia commented Sep 20, 2017

配置项不是完全覆盖的,默认 setOption(option) 会 merge 之前的 option,也就是只更新改变的部分。如果要完全覆盖,请使用 setOption(option, true)

@stale
Copy link

stale bot commented Apr 2, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale Inactive for a long time. Will be closed in 7 days. label Apr 2, 2020
@stale stale bot closed this as completed Apr 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale Inactive for a long time. Will be closed in 7 days.
Projects
None yet
Development

No branches or pull requests

2 participants