Closed CIOData closed 1 month ago
I'll take a look at that. Something I never liked about how Leaflet handled legends is that they allowed this behavior, creating really wide legends that would overlap too much onto the data unless you use <br>
tags.
However, it would be straightforward to expose a max_width
parameter for legends, allowing you to enable this.
Thanks. That would be helpful for maps generated in RStudio. I was able to fix it myself when used in a Shiny app by adjusting the CSS to width: auto; and max-width: auto;.
I'm not a fan of the leaflet legends either, but have enjoyed the outputs from leaflegend.
From: Kyle Walker @.> Sent: Friday, September 13, 2024 1:08 PM To: walkerke/mapgl @.> Cc: CIO Data @.>; Author @.> Subject: Re: [walkerke/mapgl] No option to fit title length in add_legend() for continuous values (Issue #40)
CAUTION: External Sender
I'll take a look at that. Something I never liked about how Leaflet handled legends is that they allowed this behavior, creating really wide legends that would overlap too much onto the data unless you use
tags.
However, it would be straightforward to expose a max_width parameter for legends, allowing you to enable this.
— Reply to this email directly, view it on GitHubhttps://github.com/walkerke/mapgl/issues/40#issuecomment-2349483362, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AV63IT3IUOWBNE24DEU5HSTZWML2RAVCNFSM6AAAAABODPSC7GVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGNBZGQ4DGMZWGI. You are receiving this because you authored the thread.Message ID: @.***>
I've added a new width
parameter to the legend functions, so you'll be able to specify width = "auto"
. I don't want to change the default width to that (as I want to wrap or use ellipsis by default for long titles) but longer titles are now easier to handle, especially outside Shiny.
I am adding legends to fill layers in mapgl, but can't find a way to get the box to auto fit the width of the title when using continuous values. Legends for categorical values seem to do this by default. Ideally, the width will be auto by default for continuous legends as well so that it can accommodate dynamic titles in a Shiny app.
Continuous:
Categorical: