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

动态setOption后,点击toolbox中的还原按钮,图形消失了! #2596

Closed
zhump opened this issue Feb 17, 2016 · 11 comments
Closed
Labels

Comments

@zhump
Copy link

zhump commented Feb 17, 2016

http://echarts.baidu.com/gallery/editor.html?c=dynamic-data
还用这个例子。。

setTimeout(function() {
      myChart.setOption({title:{text:22}});
}, 1000);

先动态设置一下title,
然后点击toolbox中的还原按钮,,,图形消失了,只留下了 标题 22。。。。(图形应该没变化才对)

不知道是我使用上的问题?还是echarts的bug。。。

@chaegumi
Copy link

chaegumi commented Feb 17, 2016

不是bug,是你使用不对。你应该定义一个var options={},然后 后边是要用options.title.text = '新值',然后setOption(options),这样才是正确的逻辑。

@zhump
Copy link
Author

zhump commented Feb 17, 2016

额。。。我感觉是一样的呀,你说的这种方法。
-。-
而且在demo中问题是一样的。

@SuperZDev
Copy link
Contributor

SuperZDev commented Feb 17, 2016

=_=!!!瀑布汗
不用定义新的option了,你直接修改
option.title.text= '新值' ;
也不需要setOption了,这个例子上面有个setInterval,一直在setOption。


看明白你那句错哪了吗?

@zhump
Copy link
Author

zhump commented Feb 17, 2016

噗。。。。我肯定把那个 setInterval 通通给删了。。再做测试的。。

@zhump
Copy link
Author

zhump commented Feb 17, 2016

不偷懒了,下面是完整的demo配置项

option = {
    title: {
        text: '堆叠区域图'
    },
    tooltip : {
        trigger: 'axis'
    },
    legend: {
        data:['邮件营销','联盟广告','视频广告','直接访问','搜索引擎']
    },
    toolbox: {
        feature: {
           restore : {show: true},
        }
    },
    grid: {
        left: '3%',
        right: '4%',
        bottom: '3%',
        containLabel: true
    },
    xAxis : [
        {
            type : 'category',
            boundaryGap : false,
            data : ['周一','周二','周三','周四','周五','周六','周日']
        }
    ],
    yAxis : [
        {
            type : 'value'
        }
    ],
    series : [
        {
            name:'邮件营销',
            type:'line',
            stack: '总量',
            areaStyle: {normal: {}},
            data:[120, 132, 101, 134, 90, 230, 210]
        },
        {
            name:'联盟广告',
            type:'line',
            stack: '总量',
            areaStyle: {normal: {}},
            data:[220, 182, 191, 234, 290, 330, 310]
        },
        {
            name:'视频广告',
            type:'line',
            stack: '总量',
            areaStyle: {normal: {}},
            data:[150, 232, 201, 154, 190, 330, 410]
        },
        {
            name:'直接访问',
            type:'line',
            stack: '总量',
            areaStyle: {normal: {}},
            data:[320, 332, 301, 334, 390, 330, 320]
        },
        {
            name:'搜索引擎',
            type:'line',
            stack: '总量',
            label: {
                normal: {
                    show: true,
                    position: 'top'
                }
            },
            areaStyle: {normal: {}},
            data:[820, 932, 901, 934, 1290, 1330, 1320]
        }
    ]
};
setTimeout(function() {
      myChart.setOption({title:{text:22}});
}, 1000);

@chaegumi
Copy link

chaegumi commented Feb 17, 2016

option = {
    title: {
        text: '堆叠区域图'
    },
    tooltip : {
        trigger: 'axis'
    },
    legend: {
        data:['邮件营销','联盟广告','视频广告','直接访问','搜索引擎']
    },
    toolbox: {
        feature: {
           restore : {show: true},
        }
    },
    grid: {
        left: '3%',
        right: '4%',
        bottom: '3%',
        containLabel: true
    },
    xAxis : [
        {
            type : 'category',
            boundaryGap : false,
            data : ['周一','周二','周三','周四','周五','周六','周日']
        }
    ],
    yAxis : [
        {
            type : 'value'
        }
    ],
    series : [
        {
            name:'邮件营销',
            type:'line',
            stack: '总量',
            areaStyle: {normal: {}},
            data:[120, 132, 101, 134, 90, 230, 210]
        },
        {
            name:'联盟广告',
            type:'line',
            stack: '总量',
            areaStyle: {normal: {}},
            data:[220, 182, 191, 234, 290, 330, 310]
        },
        {
            name:'视频广告',
            type:'line',
            stack: '总量',
            areaStyle: {normal: {}},
            data:[150, 232, 201, 154, 190, 330, 410]
        },
        {
            name:'直接访问',
            type:'line',
            stack: '总量',
            areaStyle: {normal: {}},
            data:[320, 332, 301, 334, 390, 330, 320]
        },
        {
            name:'搜索引擎',
            type:'line',
            stack: '总量',
            label: {
                normal: {
                    show: true,
                    position: 'top'
                }
            },
            areaStyle: {normal: {}},
            data:[820, 932, 901, 934, 1290, 1330, 1320]
        }
    ]
};
setTimeout(function() {
        option.title.text = '22';
      myChart.setOption(option);
}, 1000);

@zhump
Copy link
Author

zhump commented Feb 17, 2016

setTimeout(function() {

       var option2 = myChart.getOption();
        option.title.text = '2233';
      myChart.setOption(option);
}, 1000);

如果这么去做,是可以的。。
就是说每次setOption都得是完全的配置项吗吗?

文档不是说 setOption,默认合并之前的配置项吗

@pissang
Copy link
Contributor

pissang commented Feb 17, 2016

reset 功能好像是有这个问题,我们看一下,谢谢反馈

@chaegumi
Copy link

chaegumi commented Feb 17, 2016

前边说的定义var options={}不是说重新定义一个,只是举个例子,用法是要修改前边原有的配置项,然后setOption

@zhump
Copy link
Author

zhump commented Feb 17, 2016

#2593
#2591
各位神麻烦移步帮忙看看这个两个问题啊。。
@pissang
@SuperZDev
@chaegumi

@SuperZDev
Copy link
Contributor

SuperZDev commented Feb 17, 2016

OptionManager._optionBackup 不是最新合并后的option,recreat的时候,就完蛋了。

确定是个bug。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants