hamishgibbs / rt_vis

Interactive RT visualisation
3 stars 0 forks source link

Map selection not working on all of each country #40

Open seabbs opened 3 years ago

seabbs commented 3 years ago

It seems like with the new popups map selection is not working as expected over the whole of a countries landmass. This is a particular issue for countries like the United states and the United Kingdom.

Example: https://epiforecasts.io/covid/posts/global/

seabbs commented 3 years ago

Not seeing this issue with the simple examples in the vignettes. Means this is either linked to a fully-featured implementation or linked to a usage issue in epiforecasts/covid. Understanding which and exactly what is going on would be a good first step to resolving this.

hamishgibbs commented 3 years ago

Agreed - seems to affect Canada as well. Are you also seeing that when you hover over the US for a while and then over other countries - it takes a while for their popups to display?

I will look into why only a certain section of a geography is registering on mouse over.

I think that other behaviour may be the computation required to cycle through every feature every time the mouse moves a pixel or so and it starts to get backed up with complex geometries or something. I know rnaturalearth allows you to vary the resolution of input geographic data ('small', 'medium', 'large'). And I could reduce the number of times that a hover event is recorded maybe to speed things up.

I saw (maybe) a similar effect on this map: https://www.ons.gov.uk/visualisations/dvc811/msoamap/index.html

When you drag your mouse quickly over it is pretty slow to register the correct shape just because of how many shapes there are. Maybe something similar is going on here, but related to the detail of the geometry, not the number of shapes.

seabbs commented 3 years ago

Yes - like a brushing effect almost. It's very odd it isn't happening on the package website though.

Ah that sounds like a pretty reasonable theory. Should there be a summary step on the shapefile? Is it trying to plot all the counties in the US or something?

Yes I see what you mean. Just not clear why its only on the website versions.

hamishgibbs commented 3 years ago

I have figured this one out. But not fixed it yet.

Tooltip position is defined on the average longitude and 1/2 latitude of a given shape. So inability to hover over a certain area is because the tooltip (with 0% opacity) is covering the area that should be hovered.

Solution: Remove tooltip on each time cursor leaves a shape.

Or:

Pin tooltip to cursor position, not target shape (this may be challenging for a reason I can't remember - as event handlers have to be bound to the vis instance)

Or:

Make tooltip not selectable when it is disappeared - should shunt mouse events to the layer below the tooltip.

Will make one of these changes asap.

seabbs commented 3 years ago

ahhhh that makes sense.

I have no idea which of these solutions is preferred 😆

hamishgibbs commented 3 years ago

Haven't gotten to fixing this yet but noticed the same issue here:

https://visualization.covid19mobility.org/?date=2020-10-01&dates=2020-07-04_2020-10-04&metric=stay-put&region=GBR