Coder Social home page Coder Social logo

Comments (7)

jamiepratt avatar jamiepratt commented on May 27, 2024

Neither does this work:

jointprob/jointprob-shadow-cljs@042c593

from oz.

jamiepratt avatar jamiepratt commented on May 27, 2024

I experimented with using the "componentWillUnmount" as suggested in the clojureverse thread hook but it is not called when vegaEmbed replaces one graph with another.

I did eventually find the react-vega npm library which can be used to create a react component out of a vega or vega-lite spec and data. Whatever this component is doing under the hood it doesn't appear to be leaking memory see:

https://jointprob.github.io/jointprob-shadow-cljs/memory-efficiency-2.html which uses react-vega

In comparison to:

https://jointprob.github.io/jointprob-shadow-cljs/memory-efficiency.html which uses the oz vega-lite react component.

from oz.

metasoarous avatar metasoarous commented on May 27, 2024

@jamiepratt Thanks again for bringing this up and working on a fix!

The problem may be that the component is not technically unmounting, but just "updating". So perhaps we need componentWillUpdate to do this in addition to componentWillUnmount.

Thanks again!

from oz.

jamiepratt avatar jamiepratt commented on May 27, 2024

There is a react-vega component maintained as part of the vega project that recompiles a changed spec or uses view.change when only the data changes:

https://github.com/vega/react-vega/blob/master/packages/react-vega/src/utils/updateSingleDatasetInView.ts

from oz.

jamiepratt avatar jamiepratt commented on May 27, 2024

Discussing with jsa-aerial, Hanami maintainer, here: https://clojurians.zulipchat.com/#narrow/stream/210075-saite-dev/topic/animated.20vega-lite.20graphs/near/303463351

from oz.

metasoarous avatar metasoarous commented on May 27, 2024

Hey @jamiepratt. Sorry for the delayed response.

I actually want to do something similar to regarding calling view.change when just the data changes (see #95). I suspect that this will be much more efficient for us in ClojureScript as well, due to equality checks being more efficient with persistent data structures.

In previous discussions, I didn't realize that part of your problem was that you were trying to create an animation. Presumably just the data is changing between frames then? If this is the case, you could take advantage of Oz's :view-callback option to grab the vega view object, and use the view.change method yourself to update just the data. Please let me know if this makes sense.

Don't supposed you've tried updating your code to use componentWillUpdate, did you?

Thanks again!

from oz.

metasoarous avatar metasoarous commented on May 27, 2024

PS I've used the react-vega project in the past from vanilla JS, and had issues with it. It may have gotten better now that it's part of the official vega project, but I think there are still likely to be advantages in having our own reagent adapter; We've got enough of our own Clojurisms for managing state changes & flow that having direct access is useful. I also don't like depending on react libs when I can to avoid issues with versioning.

from oz.

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.