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
NA value not positioned correctly in legend for continuous variables #615
Comments
I have this issue as well. |
The proposed workaround works. Thank you very much, @Harrison8. I'm commenting to add that the |
Did I miss something? Where is the workaround from @Harrison8 ? |
@jzadra The workaround is the first box of code. I updated the comment to make the workaround easier to find! |
I'm trying to add this in a shiny environment but prepend does not work. I get the following error: Ignoring prepended content; prependContent can't be used in a Shiny render call. Also adding the following to my css doesn't work. .info .legend .leaflet-control br { Any suggestions? |
I was able to get it working in Shiny by converting to a raw html string with
|
In case anyone is looking for an easy in-line fix. I just created two palettes:
I then fed into the leaflet plotting commands:
This effectively removes the |
Issue: In legends for continuous variables, the NA value is out of line with the rest of the color scale. It is positioned to the right, causing the legend box to be very wide.
Workaround: Add CSS to the leaflet map using this code from the
htmlwidgets
package:Explanation of issue and workaround: The NA value used to fall below and in line with the rest of the color scale, with a line break between the color scale and the NA value. The line break requires an HTML tag
<br clear:"both">
to position it correctly in line with the rest of the color scale. The HTML tag has been removed from Leaflet, allowing the NA value to float to the right. (Leaflets produced in August of 2017 did not have this issue. Also, for discrete variables, there is no line break, and the NA value is correctly positioned in line with the other legend entries.)Currently, the legend HTML is formatted like this:
It results in the NA value moving to the right of the other legend entries, rather than below them:
The line break used to have an HTML tag
<br clear:"both">
that resulted in the NA value falling in the correct place:I don't think this issue is related to the R code that I've used, but here it is.
map
is a SpatialPolygonsDataFrame.The text was updated successfully, but these errors were encountered: