echarts issue about re-setOption after change data(graph,force)

5lhxktic  于 2022-11-03  发布在  Echarts
关注(0)|答案(3)|浏览(265)

Version

4.8.0

Steps to reproduce

需求: 关系图,鼠标滚轮缩放,页面放大之后显示所有的label(类似Map放大之后看到更详细的内容)

在zoom值到0.5时,获取option , 将label的show 改为true ,然后setoption 发现有一个初始的动画效果 , 重新绘制了图而不是在原来的图上加的.
所以我加了一行代码关闭动画 clearTimeout(myChart._chartsViews[0]._layoutTimeout); 可还是位置发生了一些改变,想问这种问题改如何解决,就这一种类型的图存在这个问题;
官方文档这样说的:所有数据的更新都通过 setOption实现,你只需要定时获取数据,setOption 填入数据,而不用考虑数据到底产生了那些变化,ECharts 会找到两组数据之间的差异然后通过合适的动画去表现数据的变化。

代码

myChart.on("graphRoam", (params) =>{
                        let option = myChart.getOption();

                        if(option.series[0].zoom>0.5&&this.isShowUserName===false){
                            option.series[0].label = {
                                show: true,
                            };
                            myChart.setOption(option);
                            clearTimeout(myChart._chartsViews[0]._layoutTimeout);
                            this.isShowUserName = true
                        }
                        if(option.series[0].zoom<=0.5&&this.isShowUserName===true){
                            option.series[0].label = {
                                show: false,
                            };
                            myChart.setOption(option);
                            clearTimeout(myChart._chartsViews[0]._layoutTimeout);
                            this.isShowUserName = false
                        }
                    })

What is expected?

how to solve it

What is actually happening?

graph (force)It's different from other chart

m3eecexj

m3eecexj1#

Hi! We've received your issue and please be patient to get responded. 🎉
The average response time is expected to be within one day for weekdays.

In the meanwhile, please make sure thatyou have posted enough image to demo your request. You may also check out the API and chart option to get the answer.

If you don't get helped for a long time (over a week) or have an urgent question to ask, you may also send an email to dev@echarts.apache.org . Please attach the issue link if it's a technical question.

If you are interested in the project, you may also subscribe our mailing list .

Have a nice day! 🍵

siotufzp

siotufzp2#

@Bfly9836 It seems you are not using English, I've helped translate the content automatically. To make your issue understood by more people, we'd like to suggest using English next time. 🤗

TRANSLATED

BODY

Version

4.8.0

steps to reproduce

Demand: Relationship diagram, mouse roller scale, display all Label after zooming, see more detailed content after zooming in maps)

When the zoom value is 0.5, get Option, change the Label's show to True, then setOption finds an initial animation effect, re-draws the diagram instead of being added on the original figure.
So I added a line of code to close the animation cleaTimeout (MyChart.ChartsViews [0] . layouttimeout); or some changes have occurred, I want to ask this problem to solve this problem, this type of figure;
The official documentation says: All data updates are implemented via SetOption, you only need to get data, setoption, without considering data, Echarts will find the difference between the two sets of data and pass appropriate Animation depends on the changes in data.

Code MyChart.on ("Graphroam", (Params) => {
Let Option = mychart.getoption ();

IF (option.series [0] .zoom> 0.5 && this.isshowusername === false) {
                        Option.series [0] .Label = {
                            Show: True,
                        }
                        MyChart.Setoption (Option);
                        Cleartimeout (MyChart._ChartsViews [0] ._ layouttimeout;
                        this.isshowusername = TRUE
                    }
                    IF (option.series [0] .ZOOM <= 0.5 && this.isshowusername === true) {
                        Option.series [0] .Label = {
                            Show: False,
                        }
                        MyChart.Setoption (Option);
                        Cleartimeout (MyChart._ChartsViews [0] ._ layouttimeout;
                        this.isshowusername = false
                    }
                })

What is expected?

How to Solve IT

What is actually happens?

Graph (Force) It's Different from Other Chart

相关问题