eurostat/gridviz

gvizLegend and tooltip_eurostat shouldn't be appended to body

wahlatlas opened this issue · 3 comments

I have to admit that I haven't fully understood how the legend works but by default it seems to be appended to the body element which is not ideal when used within larger pages where the map doesn't fill the whole viewport.

Might it be preferable to attach legend and tooltip div to the viz-container instead?

You might be right!

Until we make the change, you can specify the id of the element that you want the legend to be appended to using the 'legendDivId' property in the options object when building the app:

For example:

new gviz.App(containerDiv, {
    legendDivId: 'myLegendDiv'
}

https://eurostat.github.io/gridviz/docs/reference#app-options-object

I'll have a look into it. Also now that I think about it there is an algorithm I need to apply to the tooltip to ensure that it stays within the container (e.g. moving the tooltip to the left side of the mouse when the mouse is too close to the right border). You can see it in action here: https://observablehq.com/@joewdavies/eurostat-map-js?collection=@joewdavies/eurostat-map-js

Yes, would be nice if the tooltip would not be clipped at the edges of container. Right now it gets squeezed to some extent with text reflow but in extreme cases it gets truncated.

Should be fixed in 2.0.35

Once again, thanks for all of your feedback!