Code Monkey home page Code Monkey logo

Comments (6)

borja-munoz avatar borja-munoz commented on July 20, 2024

I understand your approach involves reading the filter state in the widget initialization and setting the selected categories (CategoryWidget, PieWidget) or bars (HistogramWidget) depending on the current filters applied to the source using the selected column property. Also, when you select a category or bar, or clear the selected filters, you will directly updating the filters in the source (as it is done today).

For the categories, I don't see a problem because we have an "IN" filter that should be easy to parse.

I'm not sure what will be the approach with selected bars in histograms. Imagine we have a histogram widget with ticks = [1, 5, 10] and we have set the following filter in the same column used by the histogram: BETWEEN 3 AND 7. What should we do in this case?

from carto-react.

Clebal avatar Clebal commented on July 20, 2024

Yes @borja-munoz, the HistogramWidget is a different case, but it can be managed easily.

In the filter we have: [1, 5], because 5 is the tick number 1, we know that selectedBars value is [1].
In the filter we have: [10, undefined], because undefined is in second place, it means that the selected bar is the last one. Then selectedBars value is [ticks.length].
In the filter we have: [undefined, 1], because undefined is in first place, it means that the selected bar is the first one. Then selectedBars value is [0].

About your first paragraph:

I would only keep the widget state in the HistogramWidget, in others I would just use filter state as selectedCategories state because it doesn't need any intermediary, you can use it directly.

from carto-react.

borja-munoz avatar borja-munoz commented on July 20, 2024

But this is not how filters are specified for sources. We specify the filter using BETWEEN (for numeric properties).

Also my question was related to the particular case where the BETWEEN interval in the filter does not match with the breaks/ticks in the histogram. If you are filtering the features with value between 3 and 7, what should you display in the [1-5] and the [5-10] bars?

from carto-react.

Clebal avatar Clebal commented on July 20, 2024

If filter value is between 3 and 7 and the ticks are [1,5,10], then those filters are not applied correctly and then the widget won't have selected bars.

from carto-react.

borja-munoz avatar borja-munoz commented on July 20, 2024

Closing this RFC as the approach for using Redux state instead of local state is being implemented in this PR: #224 by @zbigg

from carto-react.

VictorVelarde avatar VictorVelarde commented on July 20, 2024

It is indeed. We agree this is a good proposal

from carto-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.