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

Change legend scale without minima/maxima? #33

Open
bariscope opened this issue Jan 11, 2023 · 3 comments
Open

Change legend scale without minima/maxima? #33

bariscope opened this issue Jan 11, 2023 · 3 comments

Comments

@bariscope
Copy link

Hi, is it possible to modify the legend for a density map? For example, if I select colors White, Red, steps 5, and have a feature value between 0 to 100,000, the map and legend is created with 0 as White and 100,000 as red. But, I rather want it to categorize based on ranges of values. For example. <20,000, 20,000-70,000, >100,000. How is it possible to modify the legend this way?

@timwis
Copy link
Owner

timwis commented Jan 12, 2023

Hi! Unless I'm misunderstanding, this should happen automatically, via the steps argument. Would you paste a code sample to illustrate what you mean? (Either here or via codepen.com)

@bariscope
Copy link
Author

Appreciate your help! Here is the code in codepen: https://codepen.io/turen009/pen/WNKOoPV

I am looking to change two things:

  • The choropleth mapping and legend should be like this (same data used):

image

Legend:

image

Another issue is that, the map polygons have a blue border around all of them. Any way to remove the blue border?

@timwis
Copy link
Owner

timwis commented Jan 13, 2023

Hi @bariscope here's a slimmed down codepen to illustrate: https://codepen.io/timwis/pen/zYLzZaQ?editors=1011

It doesn't exactly match your image, but it's closer. Do you know the algorithm used to generate the buckets/breaks in the image? The default in leaflet-choropleth is quantile (q), but there's also equidistant, logarithmic, and k-means (see chroma docs). Just swap the 'q' in mode when you initialise your choropleth. Between that and the step count, it should hopefully get you there. Also note that the darkest value in that image is not orange but something more like #8b3e38.

Hope this helps!

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

No branches or pull requests

2 participants