Comments (15)
Sorry for the long silence on this. After talking to @swoellauer I think we have a plan of action now that should enable legends in both slideView and plainView.
from mapview.
Thanks @fdetsch ! The issue of bad font rendering of the legend under windows seemed to have been antialiasing. I have now set antialiasing = "none"
which seems to resolve this. See a73462c
from mapview.
In general, I do like the idea, however, in your example you are referring to RGB images for which a legend does not make much sense in my opinion.
@swoellauer would you have some time to look into this? 2 separate divs on each side with their own legends. I guess we could simply hijack leaflet legends for this.
from mapview.
well yeah, but one gets the gist.
from mapview.
@swoellauer I have just pushed an update that passes the filename of the legend png via the htmlwidget in plainview - RasterLayer method. Can you please check whether that is sufficient for adding a legend this way.
library(mapview)
plainview(poppendorf[[5]], legend = TRUE)
This should produce a valid x.leg_fl
on the JS side which points to the legend png.
This is a rough implementation so far as the dimensions of the png are fixed (500 x 200 pixels height and width). I am yet to come up with a clever way to estimate the ratio properly (this is mainly depending on the values of the ticks - in the example above these are largish numbers so should be fine in most occasions, but still...). Also, this means that there is some white space (actually transparent space) around the legend, meaning we will need to find a way to crop/clip the png. This could easily be done on the R side using the magick package, yet I am a bit reluctant towards adding another dependency to mapview if not really needed. So, if there is a way to crop the image in JS (without adding another library dependency) then this would be great. If there isn't, then I guess importing the relevant function from magick is something we need to consider.
@danklotz this is currently only a test implemented in plainview
for the easiest case of rendering a RatserLayer
but if this works, adding the same to slideview
should be straight forward.
from mapview.
@danklotz We have a first working legend for plainview
can you please let us know if this is what you are after? plainview(poppendorf[[5]])
@swoellauer can we make this flexible, so that plainview(poppendorf[[5]], legend = FALSE)
doesn't throw an error?
from mapview.
Sorry for the late reply.
The first commit (~8 days ago) did not work, but the current dev-version does! It looks a bit rough around the edges (as you said) but would be exactly what I would like to have (if implemented in slideview
). Thank you very much π π π
from mapview.
@danklotz could you be more specific regarding 'a bit rough around the edges'? So we can try to smooth things... ;-)
from mapview.
Oh... Well this might be picky, but the rendering/transparency of the font seems off. One can see slight white pixels around it.
from mapview.
@danklotz what OS are you using? I don't see any rendering issues on Linux...
@swoellauer I have just updated the R side of cube and plainview to include laegends. Can you adjust JS side to enable legend rendering?
from mapview.
used windows. Will check it on mac os to then
from mapview.
@danklotz slideview
and cubeview
now also have legends (for numeric data). Testing welcome. Regarding the rough look, I can replicate that on windows and will look into that. Linux seems to render fine. Did get a chance to try on mac?
from mapview.
Here's what it looks like on linux
from mapview.
Mac rendering looks fine to! Attached a screenshot of the plainview
example from above.
from mapview.
plainview
works like a charm on Windows as well:
from mapview.
Related Issues (20)
- Error with burst = TRUE and zcol ="defined", on R 4.2.1 HOT 1
- selectFeatures Error related to mode = "draw" HOT 1
- Change to new cran checks badge URL HOT 2
- Please remove dependencies on **rgdal**, **rgeos**, and/or **maptools** HOT 8
- mapview/mapedit installation on Google colab HOT 5
- Plot two or more lists containing SF collections
- Toggle legends to show/hide with layers
- mapview() mixes non-spatial tables into a single layer HOT 1
- webshot fails to save png HOT 6
- Unable to find function mapview HOT 1
- Error when include code in x argument for mapview HOT 3
- Condition has length > 1 when burst=T and row-selection HOT 2
- mapview ignoring colour palette and repeating colours HOT 1
- Error when using `popup = leafpop::popupTable(...)` with OSM data HOT 3
- Mapview - Can we set the radiobuttons also for the raster data? HOT 3
- mapview - automatic change of point/polygon/line color when switching map type HOT 3
- Unable to make maps side by side "Error: attempt to select less than one element in get1index" HOT 2
- Misalignment problem when curvilinear raster grid are ploted as regular ones
- datetime as default aesthetic HOT 11
- no package called βterraβ HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mapview.