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 choropleth legend and RE share choropleth #156

Merged
merged 19 commits into from
Nov 20, 2024
Merged

Conversation

henhuy
Copy link
Contributor

@henhuy henhuy commented May 23, 2024

Fixes #142
Fixes #141

Needs poetry update due to fix in mapengine

@henhuy henhuy requested a review from nesnoj May 23, 2024 12:40
@henhuy henhuy self-assigned this May 23, 2024
Copy link
Contributor

@nesnoj nesnoj left a comment

Choose a reason for hiding this comment

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

Thx for the fix!
The choropleth for RE share is working now.

As you set the range to 10, 100, ... the color range is not completely used leading to a map with very similar colors..which in my opinion is a drawback but I could live with that.. but it has effects like this:
image
because in one mun (Bliesdorf) the factor is 270 (which is correct) leading to 27000% but this sets the legend range to 100000%..

@henhuy
Copy link
Contributor Author

henhuy commented May 23, 2024

Indeed, the ranges are too wide now.
As for your example above - this is a tricky one, as choropleth legend and colors try to fit for all given values.
Now, range is very high, but even in older implementation the legend would go up to 27000%
We must add special behaviour for percentage choropleths in order to prevent this high values.
I will come up with a solution for both.

@nesnoj
Copy link
Contributor

nesnoj commented Jun 20, 2024

@henhuy Could you please have a look how this could be solved taking the issues from above into account?

@henhuy
Copy link
Contributor Author

henhuy commented Jun 20, 2024

Fixed RE share legend to 100% - but then many municiaplities colored dark blue as they exceed 100%.
Good, or do you want to have it somehow different?

@henhuy
Copy link
Contributor Author

henhuy commented Jul 3, 2024

Fixed RE share legend to 100% - but then many municiaplities colored dark blue as they exceed 100%. Good, or do you want to have it somehow different?

Could you have a look @nesnoj ?

@nesnoj
Copy link
Contributor

nesnoj commented Oct 8, 2024

To list the issues and their status again:

  • 0-0 in Legend
  • choropleth for RE share
  • "Fixed RE share legend to 100% - but then many municipalities colored dark blue as they exceed 100%"
    Yes, this is a problem. It is better that having 27000 % like before but we need sth like a >100% color value.
  • Colors on map do not match those from legend (shifted by 1 category)
  • Another problem that came up with your fixes: The colors for the bigger numbers are not used in many choropleths because of the larger ranges.
    Example "Gewonnene Energie aus EE (GWh)" which goes up to 1000 instead of 400 so 600-800 and 800-1000 are not used at all:

Old:
image

New:
image

Can you solve this please?

@nesnoj
Copy link
Contributor

nesnoj commented Oct 11, 2024

Could you have a look @henhuy ?

@henhuy henhuy force-pushed the fix/choropleth_legend branch from 5926c9f to d2b4a1d Compare October 15, 2024 10:26
@henhuy
Copy link
Contributor Author

henhuy commented Oct 15, 2024

Hey @nesnoj please review again.
I made a rebase - so you have to throw away your current local branch and checkout fresh.
And you have to update poetry, as i had to update mapengine.

Please check different choropleths and especially chorpleths for energy shares (%)

@nesnoj
Copy link
Contributor

nesnoj commented Oct 18, 2024

From today @henhuy

  • Colors seem to be continuous and do not match discrete colors
  • Increase default number of legend colors from 5 to 6
  • The param num_colors in static/config/choropleths.json seem to have no effect 🤔

@henhuy henhuy force-pushed the fix/choropleth_legend branch from 6367e4d to 7e2e65f Compare November 19, 2024 12:35
@henhuy
Copy link
Contributor Author

henhuy commented Nov 19, 2024

From today @henhuy

* Colors seem to be continuous and do not match discrete colors

Cannot change continuous coloring - there is no option to do so...
Only workaround would be to adapt feature data to match legend colors - would only do this if really necessary.

* Increase default number of legend colors from 5 to 6

Done.

* The param `num_colors` in `static/config/choropleths.json` seem to have no effect 🤔

There is a mismatched between chorpleth names i choropleth.json and choropleth.py. Once keys are mapping, number of legend entries gets adapted. For now, this is not needed, as I simply changed default number to 6 in mapengine.

@henhuy
Copy link
Contributor Author

henhuy commented Nov 19, 2024

Would like to merge now and encounter continuous coloring in a new issue if necessary.

@nesnoj
Copy link
Contributor

nesnoj commented Nov 19, 2024

Thx @henhuy for the fix, looks good now! And do not worry about the continuous coloring.
However, the result popups do not work and raise

  File "/app/digiplan/map/charts.py", line 53, in render
    values = self.chart_data.iloc[i]
AttributeError: 'list' object has no attribute 'iloc'

pointing to your "Minor fix" in 4f0d002 . After undoing popups work again. What's the reason for this change?

@henhuy
Copy link
Contributor Author

henhuy commented Nov 20, 2024

What's the reason for this change?

A shit, this is due to pandas warnings in the console - but apparently chart_data isn't always a pandas.Series but can be a simple list as well. I will apply a quick fix.

@henhuy
Copy link
Contributor Author

henhuy commented Nov 20, 2024

I will apply a quick fix.

Done.

@nesnoj
Copy link
Contributor

nesnoj commented Nov 20, 2024

I will apply a quick fix.

Done.

Great, thanks! I'm happy to finally merge this :)

@nesnoj nesnoj merged commit 1a9ba4a into dev Nov 20, 2024
1 check failed
@nesnoj nesnoj deleted the fix/choropleth_legend branch November 20, 2024 07:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Choropleth for RE share not working 0 - 0 in choropleth legend value
2 participants