Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(grapher): don't offer non-plottable entities for selection #2763

Merged
merged 7 commits into from
Dec 18, 2023

Conversation

sophiamersmann
Copy link
Member

@sophiamersmann sophiamersmann commented Oct 13, 2023

Problem

  • Fixes a bug where entities were offered for selection that couldn't be plotted
  • This happened for:
    • StackedArea and StackedBar charts (default settings)
    • LineCharts if the config's missingDataStrategy was set to hide

Technical details

  • The chart interface is extended by an additional (but optional) chart table transform, transformTableForSelection
    • If given, transformTableForSelection is responsible to exclude all entities that are not plottable
  • grapher.tableForSelectioncalls transformTableForSelection of the current chart instance (if defined)
  • transformTableForSelection has been implemented for a subset of chart types whose entity selector was sometimes buggy (see above)
    • it runs basic clean up transforms, interpolation, and the filter transforms that implement the specified missing data strategy (only if necessary)

@sophiamersmann sophiamersmann force-pushed the hide-non-plottable-entities-in-selector branch from cd2a3c2 to 8845200 Compare October 16, 2023 11:24
@sophiamersmann sophiamersmann marked this pull request as ready for review October 18, 2023 09:34
@sophiamersmann sophiamersmann force-pushed the hide-non-plottable-entities-in-selector branch from 994659e to 45d7e0f Compare October 25, 2023 07:41
Copy link
Member

@marcelgerber marcelgerber left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work, overall I think this makes sense.

However, I'm thinking that the whole tableForSelection concept is hindering us a bit, and it would be a bit more straightforward to just make availableEntities an (optional) chart instance getter.

That way, any charts could run some code to tell grapher which entities they have available (potentially by running table transforms), and otherwise, they just default to this.inputTable.availableEntities.
Overall, just getting rid of the tableForSelection indirection in between. An OwidTable is not the best format to communicate available entities, I think...

@sophiamersmann
Copy link
Member Author

mhh.. I mean for now we're only grabbing the available entities, but I imagine that Christian builds the new entity selector on top of a table – so we might be a little more flexible in the future if chart instances were allowed to customise that table (cc @samizdatco)

@marcelgerber
Copy link
Member

mhh.. I mean for now we're only grabbing the available entities, but I imagine that Christian builds the new entity selector on top of a table – so we might be a little more flexible in the future if chart instances were allowed to customise that table

Ah, you're right about that of course. Good thinking!

Copy link

This PR has had no activity within the last two weeks. It is considered stale and will be closed in 3 days if no further activity is detected.

@github-actions github-actions bot added the stale label Nov 14, 2023
@sophiamersmann sophiamersmann force-pushed the hide-non-plottable-entities-in-selector branch from c3db031 to 4fcd7e8 Compare November 28, 2023 09:22
@samizdatco
Copy link
Contributor

samizdatco commented Nov 28, 2023

mhh.. I mean for now we're only grabbing the available entities, but I imagine that Christian builds the new entity selector on top of a table – so we might be a little more flexible in the future if chart instances were allowed to customise that table (cc @samizdatco)

I didn't change much in terms of how the entity-selector populates its list of items: they're still coming from the grapher object's selection attribute (and in particular that SelectionArray's availableEntities list):

@computed private get searchableEntities(): SearchableEntity[] {
const { selectedEntityNames } = this.selectionArray
return this.sortedAvailableEntities
.filter((name) => !selectedEntityNames.includes(name))
.map((name) => {
return { name } as SearchableEntity
})
}

The rest of my changes can be found in https://github.com/owid/owid-grapher/commits/entity-selector-redesign

@sophiamersmann sophiamersmann force-pushed the hide-non-plottable-entities-in-selector branch from 4fcd7e8 to 3e99975 Compare December 18, 2023 10:33
@sophiamersmann sophiamersmann merged commit 4bad116 into master Dec 18, 2023
14 of 15 checks passed
@sophiamersmann sophiamersmann deleted the hide-non-plottable-entities-in-selector branch December 18, 2023 13:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Some charts allow selecting entities for which there is no data
3 participants