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

Closed
zhump opened this Issue Feb 17, 2016 · 11 comments

Comments

Projects
None yet
5 participants
@zhump

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

This comment has been minimized.

Show comment
Hide comment
@chaegumi

chaegumi Feb 17, 2016

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

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

@zhump

This comment has been minimized.

Show comment
Hide comment
@zhump

zhump Feb 17, 2016

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

zhump commented Feb 17, 2016

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

@SuperZDev

This comment has been minimized.

Show comment
Hide comment
@SuperZDev

SuperZDev Feb 17, 2016

Contributor

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


看明白你那句错哪了吗?

Contributor

SuperZDev commented Feb 17, 2016

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


看明白你那句错哪了吗?

@zhump

This comment has been minimized.

Show comment
Hide comment
@zhump

zhump Feb 17, 2016

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

zhump commented Feb 17, 2016

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

@zhump

This comment has been minimized.

Show comment
Hide comment
@zhump

zhump 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);

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

This comment has been minimized.

Show comment
Hide comment
@chaegumi

chaegumi 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);
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

This comment has been minimized.

Show comment
Hide comment
@zhump

zhump Feb 17, 2016

setTimeout(function() {

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

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

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

zhump commented Feb 17, 2016

setTimeout(function() {

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

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

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

@pissang

This comment has been minimized.

Show comment
Hide comment
@pissang

pissang Feb 17, 2016

Contributor

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

Contributor

pissang commented Feb 17, 2016

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

@chaegumi

This comment has been minimized.

Show comment
Hide comment
@chaegumi

chaegumi Feb 17, 2016

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

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

@zhump

This comment has been minimized.

Show comment
Hide comment
@zhump

zhump Feb 17, 2016

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

zhump commented Feb 17, 2016

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

@SuperZDev

This comment has been minimized.

Show comment
Hide comment
@SuperZDev

SuperZDev Feb 17, 2016

Contributor

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

确定是个bug。

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