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

Choropleth customize #3154

Merged
merged 8 commits into from
May 7, 2019
Merged

Conversation

deecay
Copy link
Contributor

@deecay deecay commented Dec 1, 2018

New map for Choropleth: Japanese Prefectures


Trying to add sub-country level choropleth. I hope this PR will make choropleth extensible, and will be the guide for adding other regions, such as US states, etc.

Screenshot: Population per prefecture
image

Discussion points


  • Is "Map Type" the right name to switch/select geojson files?
  • "Country" in editor should be changed to "Map", such as "Country code column" => "Map code column"?
  • "country" in source code. What should we do about those? Rename all occurrences to something else?

Query


Example query used in the above screenshot.

select 'Tokyo' as "pref", 'JP-13' as "Iso", '東京都' as "pref_local", 13515271 as population from events union
select 'Kanagawa' as "pref", 'JP-14' as "Iso", '神奈川県' as "pref_local", 9126214 as population from events union
select 'Osaka' as "pref", 'JP-27' as "Iso", '大阪府' as "pref_local", 8839469 as population from events union
select 'Aichi' as "pref", 'JP-23' as "Iso", '愛知県' as "pref_local", 7483128 as population from events union
select 'Saitama' as "pref", 'JP-11' as "Iso", '埼玉県' as "pref_local", 7266534 as population from events union
select 'Chiba' as "pref", 'JP-12' as "Iso", '千葉県' as "pref_local", 6222666 as population from events union
select 'Hyogo' as "pref", 'JP-28' as "Iso", '兵庫県' as "pref_local", 5534800 as population from events union
select 'Hokkaido' as "pref", 'JP-01' as "Iso", '北海道' as "pref_local", 5381733 as population from events union
select 'Fukuoka' as "pref", 'JP-40' as "Iso", '福岡県' as "pref_local", 5101556 as population from events union
select 'Shizuoka' as "pref", 'JP-22' as "Iso", '静岡県' as "pref_local", 3700305 as population from events union
select 'Ibaraki' as "pref", 'JP-08' as "Iso", '茨城県' as "pref_local", 2916976 as population from events union
select 'Hiroshima' as "pref", 'JP-34' as "Iso", '広島県' as "pref_local", 2843990 as population from events union
select 'Kyoto' as "pref", 'JP-26' as "Iso", '京都府' as "pref_local", 2610353 as population from events union
select 'Miyagi' as "pref", 'JP-04' as "Iso", '宮城県' as "pref_local", 2333899 as population from events union
select 'Niigata' as "pref", 'JP-15' as "Iso", '新潟県' as "pref_local", 2304264 as population from events union
select 'Nagano' as "pref", 'JP-20' as "Iso", '長野県' as "pref_local", 2098804 as population from events union
select 'Gifu' as "pref", 'JP-21' as "Iso", '岐阜県' as "pref_local", 2031903 as population from events union
select 'Tochigi' as "pref", 'JP-09' as "Iso", '栃木県' as "pref_local", 1974255 as population from events union
select 'Gunma' as "pref", 'JP-10' as "Iso", '群馬県' as "pref_local", 1973115 as population from events union
select 'Okayama' as "pref", 'JP-33' as "Iso", '岡山県' as "pref_local", 1921525 as population from events union
select 'Fukushima' as "pref", 'JP-07' as "Iso", '福島県' as "pref_local", 1914039 as population from events union
select 'Mie' as "pref", 'JP-24' as "Iso", '三重県' as "pref_local", 1815865 as population from events union
select 'Kumamoto' as "pref", 'JP-43' as "Iso", '熊本県' as "pref_local", 1786170 as population from events union
select 'Kagoshima' as "pref", 'JP-46' as "Iso", '鹿児島県' as "pref_local", 1648177 as population from events union
select 'Okinawa' as "pref", 'JP-47' as "Iso", '沖縄県' as "pref_local", 1433566 as population from events union
select 'Shiga' as "pref", 'JP-25' as "Iso", '滋賀県' as "pref_local", 1412916 as population from events union
select 'Yamaguchi' as "pref", 'JP-35' as "Iso", '山口県' as "pref_local", 1404729 as population from events union
select 'Ehime' as "pref", 'JP-38' as "Iso", '愛媛県' as "pref_local", 1385262 as population from events union
select 'Nagasaki' as "pref", 'JP-42' as "Iso", '長崎県' as "pref_local", 1377187 as population from events union
select 'Nara' as "pref", 'JP-29' as "Iso", '奈良県' as "pref_local", 1364316 as population from events union
select 'Aomori' as "pref", 'JP-02' as "Iso", '青森県' as "pref_local", 1308265 as population from events union
select 'Iwate' as "pref", 'JP-03' as "Iso", '岩手県' as "pref_local", 1279594 as population from events union
select 'Oita' as "pref", 'JP-44' as "Iso", '大分県' as "pref_local", 1166338 as population from events union
select 'Ishikawa' as "pref", 'JP-17' as "Iso", '石川県' as "pref_local", 1154008 as population from events union
select 'Yamagata' as "pref", 'JP-06' as "Iso", '山形県' as "pref_local", 1123891 as population from events union
select 'Miyazaki' as "pref", 'JP-45' as "Iso", '宮崎県' as "pref_local", 1104069 as population from events union
select 'Toyama' as "pref", 'JP-16' as "Iso", '富山県' as "pref_local", 1066328 as population from events union
select 'Akita' as "pref", 'JP-05' as "Iso", '秋田県' as "pref_local", 1023119 as population from events union
select 'Kagawa' as "pref", 'JP-37' as "Iso", '香川県' as "pref_local", 976263 as population from events union
select 'Wakayama' as "pref", 'JP-30' as "Iso", '和歌山県' as "pref_local", 963579 as population from events union
select 'Yamanashi' as "pref", 'JP-19' as "Iso", '山梨県' as "pref_local", 834930 as population from events union
select 'Saga' as "pref", 'JP-41' as "Iso", '佐賀県' as "pref_local", 832832 as population from events union
select 'Fukui' as "pref", 'JP-18' as "Iso", '福井県' as "pref_local", 786740 as population from events union
select 'Tokushima' as "pref", 'JP-36' as "Iso", '徳島県' as "pref_local", 755733 as population from events union
select 'Kochi' as "pref", 'JP-39' as "Iso", '高知県' as "pref_local", 728276 as population from events union
select 'Shimane' as "pref", 'JP-32' as "Iso", '島根県' as "pref_local", 694352 as population from events union
select 'Tottori' as "pref", 'JP-31' as "Iso", '鳥取県' as "pref_local", 573441 as population from events

@deecay
Copy link
Contributor Author

deecay commented Dec 2, 2018

countryCodeTypes are fixed in line 269, populateCountryCodeTypes. I made it a function to make it watch-able. This was needed to respond to mapType change.

I will look into the inferCountryCodeType().

@kravets-levko
Copy link
Collaborator

I mean that you also should update $scope.templateHint= in line 249 - it has references to countryCodeTypes

@deecay
Copy link
Contributor Author

deecay commented Dec 2, 2018

Ah, got it. Will do that, too.

@deecay
Copy link
Contributor Author

deecay commented Dec 2, 2018

@kravets-levko, Both hint and infer are fixed.

Copy link
Collaborator

@kravets-levko kravets-levko left a comment

Choose a reason for hiding this comment

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

Looks quite good 👍

@deecay
Copy link
Contributor Author

deecay commented Dec 2, 2018

@kravets-levko
Thanks for the review. How about the discussion points in the initial description? No need to worry?

@kravets-levko
Copy link
Collaborator

You can rename only labels in the UI; keep names of variables as is (otherwise you'll need to create a migration). I have some ideas how to improve the whole visualization, and it will require migration as well, so I'll give proper names when doing my implementation.

@deecay
Copy link
Contributor Author

deecay commented Dec 2, 2018

Understood. I will change the UI labels.

@deecay
Copy link
Contributor Author

deecay commented Dec 2, 2018

By the way, I am changing the way tooltips are being shown. Now the position is automatically calculated and fixed, but I see couple of weird cases. So I am changing it to 'stick' to mouse movements.

Screenshots:
image
image
image
You can see Tokyo's tooltip cut off at the bottom because Tokyo is long in North-South, having islands to the south.

@deecay deecay changed the title [WIP] Choropleth customize Choropleth customize Dec 2, 2018
@arikfr
Copy link
Member

arikfr commented Dec 4, 2018

Thank you @deecay, this is really great! And I hope that we can add more regions in time. 👌

The bad news are that we're currently in the middle of a migration React. #2988 ports all current visualizations to React. We can't afford to add any significant changes to the visualizations until #2988 is merged, as otherwise it will be a never ending effort :-(

This means that we can't merge this until #2988 is merged and once it's merged, this pull request will need to be updated to use React. I know this adds extra work for you, and I apologize for this. Hopefully most of work will be simple "translation", as the bulk of the work is probably figuring out the details, which you already did.

Thanks again and apologies for the situation this created. When the time comes, we can try and help with the migration of this pull request to React.

@deecay
Copy link
Contributor Author

deecay commented Dec 4, 2018

No worries at all @arikfr. I will learn the trick from @washort 😄. I can update this PR myself after #2988 is merged.

@deecay deecay requested a review from kravets-levko May 6, 2019 20:24
@deecay
Copy link
Contributor Author

deecay commented May 6, 2019

Merged React related changes.

@kravets-levko kravets-levko merged commit b7b345d into getredash:master May 7, 2019
@kravets-levko
Copy link
Collaborator

@deecay Thanks a lot! 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants