Closed lindsayplatt closed 4 years ago
First - what does the top SVG map do? It has working hovers and tooltips. Are those inline?
Second - @jread-usgs and I are working on coding up the SVG to not have a rectangle built for every single bar in every state. That should probably decrease the overall SVG size by a lot and may make it possible to do the inline tooltip approach without performance issues.
I can help weigh in on this if that would be useful. Perhaps a quick video meeting today?
Yes, the top svg map uses inline svg as well. While we are able to insert the svg using the separate file we (myself and @abriggs-usgs ) could not get the tooltip to work in that way. To mimic the initial chart we attempted to implement using inline svg which seemed appropriate for the interactivity but this caused performance issues. With a different implementation for the tooltip this may work, we think the file size would need to be ~1/4 of what it currently is for optimal performance.
I assume Lindsay's new file will be way smaller. Instead of each state/terr/DC having 130 <rect/>
, it will have one. So 6.7k fewer lines in the svg.
Seems tips aren't working on the cartogram for Firefox
They do work for the top SVG (the animated one). Seems let translate_elements = window.getComputedStyle(evt.target.parentElement).transform;
isn't working and this gets "none" in FF
A different way of getting style works:
evt.target.parentElement.getAttribute('transform')
"translate(372.045 175.84)"
but the format of that is different
Ok, that's a bummer about Firefox. Are you saying that the format of the result of evt.target.parentElement.getAttribute('transform')
is different from the getComputedStyle
method? If so, should be easy to change the string handling commands in subsequent lines. I can work on this fix if you would like.
Yes, the result of the getAttribute
is (I think) just the exact string in the transform. So it could be something like translate(1,4)scale(1.5,5)
or translate(1 4)scale(1.5 5)
, which makes it a little harder to make assumptions for parsing it. But since you are automating the code that creates the transform, there is less worry that those string formats might change...your solution was more robust and better, but the FF issue throws a bit of a wrench in it.
Right. And a quick Google shows that FF does indeed have a reported bug with getComputedStyle. The reported bug is from 2012, so I don't think we can rely on it being fixed 😉
See the section called "More on getComputedStyle" here: https://stackoverflow.com/a/32296604
Fixed that last issue in https://github.com/usgs-makerspace/gages-through-the-ages/pull/172
From @collnell: