Giter VIP home page Giter VIP logo

Comments (8)

hustcc avatar hustcc commented on May 12, 2024

其实并不需要这么比喻,直接说具体问题也许更加容易懂。

你 setState 之后肯定会重新 render,但是有 option 并没有变化,所以图形上感觉不到区别。你可以尝试加一些动画试试看。

from echarts-for-react.

waitinghope avatar waitinghope commented on May 12, 2024

@hustcc thank you. 对,我知道图没有变化,但是实际上echart 做了render这个动作。我的目标是不让echart做render。

一个图感觉不明显,如果页面有20几个的话,页面就会hang住。。。。。
现在我的做法是写了一个shouldupdate来判断数据,想看看有没有其它办法。
因为感觉react并没有控制echart.init出来的那个div里的canvas

from echarts-for-react.

hustcc avatar hustcc commented on May 12, 2024

我理解的你的意思了,如果按照我这里组件代码:

componentDidUpdate() {
    this.renderEchartDom();
    this.bindEvents(this.getEchartsInstance(), this.props.onEvents || []);
},

只有 componentDidUpdate 的时候才会触发重新渲染,我来测试一下,如果外部组件 state 变化,但是ReactEcharts 的属性不变化的情况下,看会不会触发图表渲染。

from echarts-for-react.

waitinghope avatar waitinghope commented on May 12, 2024

https://medium.com/@arikmaor/react-redux-performance-tuning-tips-cef1a6c50759#.f9uq92zhu
按照这个文章说的,react首先生成virtual dom,然后比较前后两个virtual dom.
我觉得react就认为

这个总是不同的。

from echarts-for-react.

waitinghope avatar waitinghope commented on May 12, 2024

<div><canvas></canvas></div>

from echarts-for-react.

hustcc avatar hustcc commented on May 12, 2024

我加入 30 个 charts,每秒刷一次,确实有卡顿的感觉。

如果我这边添加 shouldupdate 来判断传入的属性是不是有更新,其实也需要对 option 等很多的属性进行deep equal 比较,应该也是比较消耗的。

from echarts-for-react.

waitinghope avatar waitinghope commented on May 12, 2024

额,sorry,我不是想让你加判断。因为其实大家用这个一般也会在外面包一层,然后添加自己的业务逻辑。大家可以自己处理shouldUpdata.

我想知道怎么能不让echart在数据明明没有变化的时候不render canvas。
就是option没变化,echart还是做了canvas的重绘,这个其实是比较重的一个操作,从chrome的性能分析工具上来看。

from echarts-for-react.

hustcc avatar hustcc commented on May 12, 2024

那估计得 echarts 来解决了。这个估计有点难了。

from echarts-for-react.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.