GithubHelp home page GithubHelp logo

Comments (8)

bpostlethwaite avatar bpostlethwaite commented on July 30, 2024

Note that right now if you click legend HIDE the positioning field still shows up as MenuPanel triggers section visibility . We should turn that off and test.

from react-chart-editor.

bpostlethwaite avatar bpostlethwaite commented on July 30, 2024

<Section> is passing in its context to unpackPlotProps which may be different than the context received by the children. For example if you have a structure like this:

<TraceConnectedPanel />
    <Section />
        <LayoutConnectedField />

<Section> will only see TraceConnected context objects and unpackPlotProps will return a different value then what will be computed by its <LayoutConnectedField> child. This is really bad... since the visibility will be computed incorrectly.

This is blocking adding layout attributes inside a Tracepanel. For example boxgap and friends.

cc @alexcjohnson sorta stuck on this one. We may have to rethink the way visibility is handled...

from react-chart-editor.

bpostlethwaite avatar bpostlethwaite commented on July 30, 2024

https://medium.com/@mweststrate/how-to-safely-use-react-context-b7e343eff076 Hmmm we may have to rethink our use of context period.

from react-chart-editor.

bpostlethwaite avatar bpostlethwaite commented on July 30, 2024

One way would be to also define defaultProps for the container attr like fullLayout or fullData. Then the <Section> will see that prop and could use it. This would be set on the higher order component like connectLayoutToPlot.

I'll investigate that.

from react-chart-editor.

bpostlethwaite avatar bpostlethwaite commented on July 30, 2024

So this is all <Section>s fault. We need to work around the fact that <Section> precomputes plotProps using the wrong context. This has 2 negative side effects.

First is that it just computes the wrong visibility for the field. Second, once it has computed the wrong plotProps the default behaviour of a connectToContainer component is to not recompute them but simply used the ones passes to it by <Section> (or whatever parent). This saves some computation for all the components nested in <Section> but bites us here.

One way to get around the visibility problem is with a modifyPlotProps function in the higher order component that wraps container nested fields. This has been used a bunch of other times to customize the behaviour of certain fields. To work around the second case we will need to signal to connectToContainer that it needs to recompute plotProps.

I am going to move some of the other simple exceptions to a shame.js file and add the layout-inside-trace <Gap> widgets in there as well. Once I have progressed further it will hopefully become more apparent what exceptions need to be refactored away.

from react-chart-editor.

bpostlethwaite avatar bpostlethwaite commented on July 30, 2024

Also re: shouldComponentUpdate and context. This is pretty bad overall but if we are clear that any non-Editor intermediary component that is inserted into the graph and wants to implement shouldComponentUpdate needs to check the Editor.revision number we should be ok. If it increases the component must update. Then whenever we change context we make sure the revision number is always incremented. The rudiments for this are already in place. See #61

from react-chart-editor.

bpostlethwaite avatar bpostlethwaite commented on July 30, 2024

workaround here #91

from react-chart-editor.

bpostlethwaite avatar bpostlethwaite commented on July 30, 2024

closed by #99

from react-chart-editor.

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.