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

adjust labels of addLegendSize #60

Closed
mtennekes opened this issue Feb 24, 2023 · 9 comments
Closed

adjust labels of addLegendSize #60

mtennekes opened this issue Feb 24, 2023 · 9 comments
Assignees
Labels
enhancement New feature or request

Comments

@mtennekes
Copy link

I'm working on implementing leaflegend in tmap v4 (r-tmap/tmap#699). One important question:

Can the legend labels be specified in addLegendSize? I'd like to be able to specify any text (e.g. "Very large", "Large", "Medium", "Small") for the symbol sizes.

@tomroh
Copy link
Owner

tomroh commented Feb 24, 2023

Do you mean overwrite 200, 400, 600 with small, medium large?

That's not currently implemented with addLegendSize but is possible with a bit more sweat equity and addLegendImage. I should be able to add that in.

@tomroh tomroh self-assigned this Feb 25, 2023
@tomroh tomroh added the enhancement New feature or request label Feb 25, 2023
@tomroh
Copy link
Owner

tomroh commented Feb 25, 2023

  • add option to pass named vector of breaks

@mtennekes
Copy link
Author

Yes, indeed. That would be great!

From how I understand your (great) package, I will use:

  • addLegendNumeric for color gradients
  • addLegendSize for symbols varying in size (and optionally color or fill)
  • addLegendSymbols for symbols varying in shape and/or color/fill)
  • addLegendLine for line width (and optionally color or fill)

Is addLegendImage the most flexible? Is that correct or do you have suggestions?

Is it possible to generate symbols with makeSymbol and feed that into addLegendImage? If so, I would consider that (because it gives more options. e.g. to vary size, color and shape at the same time.

Btw, can I show a label for missing values in the addLegendNumeric?

@mtennekes
Copy link
Author

Just playing with addLegendImage in combination with makeSymbol: awesome! Just what I need.
From the source code of makeSymbol I figured out how to change the stroke width: 'stroke-width' = 0.1. Why not just add an argument strokeWidth?

@tomroh
Copy link
Owner

tomroh commented Feb 26, 2023

There are some helper functions too: https://roh.engineering/posts/2021/05/map-symbols-and-size-legends-for-leaflet/

e.g. makeSymbolSize

addLegendImage is the most versatile of those functions, but I think in terms of overwriting text. addLegendFactor can satisfy most of what you need.

Instead of listing all presentation attributes out as arguments, you can use ... to pass them on. strokeWidth is needed for some internal alignment and sizing calculations and I was trying to create a consistent "naming" convention with the "leaflet" package which I wasn't a fan of weight.

@tomroh
Copy link
Owner

tomroh commented Feb 26, 2023

I'm thinking of adding functionality to addLegendSize where you can pass the breaks as a named list e.g. c(small = 10, medium = 20, large = 30). The names would be the label/text.

@chrispmad
Copy link

I was looking for exactly this functionality in addLegendSize. Thank you, @tomroh, for this superb package and for adding features like this!

@tomroh
Copy link
Owner

tomroh commented Mar 4, 2023

a75fd0f

@tomroh
Copy link
Owner

tomroh commented Mar 4, 2023

Can the legend labels be specified in addLegendSize? I'd like to be able to specify any text (e.g. "Very large", "Large", "Medium", > "Small") for the symbol sizes.
Btw, can I show a label for missing values in the addLegendNumeric?

Moving this to #62. The addLegendNumeric is more complex than the other legends and spacing labels becomes an issue for overriding the breaks.

This is complete for other legend functions.

@tomroh tomroh closed this as completed Mar 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants