-
-
Notifications
You must be signed in to change notification settings - Fork 229
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
🎉 (entity selector) sort by external indicators #3466
Conversation
This stack of pull requests is managed by Graphite. Learn more about stacking. Join @sophiamersmann and the rest of your teammates on Graphite |
9762a62
to
ea10308
Compare
ea10308
to
ce3b04f
Compare
9b0e9a9
to
33a2d00
Compare
ce3b04f
to
a5a8afc
Compare
33a2d00
to
85b3c66
Compare
a5a8afc
to
f475230
Compare
5977c2b
to
4fac008
Compare
4fac008
to
3071934
Compare
e779013
to
265c819
Compare
3071934
to
ac6a353
Compare
265c819
to
d1b0586
Compare
ac6a353
to
9a05e58
Compare
d1b0586
to
686872e
Compare
9a05e58
to
d6a6db6
Compare
686872e
to
ae96066
Compare
34799bd
to
c4170b8
Compare
0997d6c
to
182bd44
Compare
182bd44
to
28a40e3
Compare
c4170b8
to
e956f8d
Compare
28a40e3
to
0deb912
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, this works well!
const activePopulationColumn = this.numericalChartColumns.find( | ||
(column) => | ||
isPopulationVariableId(column.slug) || | ||
!!makeColumnLabel(column).match(/\bpopulation\b/i) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, this regex will also match "Population density", "Female population", "Share of population in poverty", etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah... but I can't think of a better way to detect population/GDP per capita indicators. Alternatively, we could rely on isPopulationVariableId
only and ask d&r for a similar list of GDP per capita indicators. Do you reckon that would be better?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For population, I think it is best to rely on isPopulationVariableId
only and not use a regex since we'd get many spurious matches (Datasette)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, agreed.
Or otherwise, match only /Population( \(historical estimates\))?/
, which currently finds exactly these four.
| CoreColumn | ||
| undefined { | ||
const activeGdpPerCapitaColumn = this.numericalChartColumns.find( | ||
(column) => !!makeColumnLabel(column).match(/\bgdp per capita\b/i) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar here: This'll also match any variable that contains % of GDP per capita
, for example.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GDP per capita is different because we have lots of GDP per capita variations like GDP per capita (constant 2015 US$)
or Real GDP per capita (2011$)
that are often simply referred to as "GDP per capita" in charts (Datasette; example chart). In such cases, using a second, slightly different GDP per capita version in the entity selector would be confusing. So, I think matching the name makes sense here. But I updated the regex to make sure that we're not matching "GDP per capita" if it's in parens, like Government expenditure per student, primary (% of GDP per capita)
.
There are some indicators that we'll match incorrectly (like Growth rate of GDP per capita
or Affordability of cigarettes: percentage of GDP per capita required to purchase 2000 cigarettes of the most sold brand
), which means that we'll fail to offer "GDP per capita" as a sorting option, which I think is acceptable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, agreed. Good on you for pointing out that the outcome of a false positive is simply that we're not offering GDP per capita for sorting in that case, which is totally accepting.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What I don't quite like here is how set-in-stone these two variables are: There are many methods that have "population" or "gdp" in their name, and all of that makes it quite hard to add any other such indicators in the future.
More ideally, we would have a more configurable set; something like
const INDICATORS_TO_LOAD = [{
key: "population",
name: "Population",
indicatorId: POPULATION_INDICATOR_ID_USED_IN_ENTITY_SELECTOR,
columnNameRegex: /\bpopulation\b/i
}, // ...
]
could work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had refactored the code at some point to allow for a list of external indicators like that 👆🏻, but it made the code harder to read, and at the same time, I think it's quite unlikely that we'll keep adding external indicators. I don't have a strong opinion though – happy to refactor if you want me to!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Earlier today, I was thinking that we will probably unify the explorer entity selector with the grapher entity selector at some point.
It's a bit weird at the moment that the explorer entity selector is shown on the left, that it is also visible on the map and table tabs, etc.
Explorers currently have their own options for sorting, which can be set in the spreadsheet. Basically, they can be any column of any csv file that's being used in the explorer, including ones that haven't yet been fetched.
I'm not sure what the future of explorers entails, exactly - I think we want to move away a bit from csv's as a data source.
But still, supporting the current explorer feature set would be easier if it was easier to set/extend the set of sort indicators.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not something for now, though, just something to keep in mind for the future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point! That would def make it easier :)
e956f8d
to
9bb9dc9
Compare
0deb912
to
ae2c1d3
Compare
9bb9dc9
to
b719487
Compare
ae2c1d3
to
4c54ffd
Compare
b719487
to
8d26977
Compare
4c54ffd
to
c40d2b4
Compare
8d26977
to
797f3fd
Compare
c40d2b4
to
705194c
Compare
797f3fd
to
0829e33
Compare
705194c
to
4f2c915
Compare
0829e33
to
94b6a61
Compare
4f2c915
to
354fcd8
Compare
Quick links (staging server):
Login:
SVG tester:Number of differences (default views): 1237Number of differences (all views): 389 Edited: 2024-05-02 14:45:35 UTC |
Merge activity
|
94b6a61
to
a56d68f
Compare
354fcd8
to
8004a9d
Compare
Cycle 2024.2: Entity selector | Designs
Summary
Offers to sort by "Population" and "GDP per capita", even if the chart doesn't include population or GDP per capita indicators.
Details
regions.json
file is not perfect since the default population and GDP per capita indicators that we are using have data for a few entities that are not listed inregions.json
(see details below)Entities of the population or GDP per capita indicator that are not included in the `regions.json` file
- Africa (UN)
- Asia (UN)
- Europe (UN)
- High-income countries
- Latin America and the Caribbean (UN)
- Low-income countries
- Lower-middle-income countries
- Northern America (UN)
- Oceania (UN)
- Upper-middle-income countries
- East Asia and Pacific (WB)
- Europe and Central Asia (WB)
- High-income countries
- Latin America and Caribbean (WB)
- Low-income countries
- Lower-middle-income countries
- Middle East and North Africa (WB)
- Middle-income countries
- North America (WB)
- South Asia (WB)
- Sub-Saharan Africa (WB)
- Upper-middle-income countries
SVG tester
The SVG tester fails due to the changes in #3373