subwayMap | A jquery plugin to render data as a subway map visualization | Data Visualization library
kandi X-RAY | subwayMap Summary
kandi X-RAY | subwayMap Summary
A jquery plugin to render data as a subway map visualization.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of subwayMap
subwayMap Key Features
subwayMap Examples and Code Snippets
Community Discussions
Trending Discussions on subwayMap
QUESTION
I'm using D3 to load an external SVG map that isn't using topojson (as the map was hand created and non a traditional map). I'm trying to target the elements #lines path
so that when clicked, each path zooms and fills its bounding box.
I'm trying to use this example from Mike Bostock but can't figure out how to replicate it with the data that isn't using topojson. See this line:
.data(topojson.feature(us, us.objects.states).features)
It this even possible?
Here is the code I'm using to load the SVG.
...ANSWER
Answered 2020-Feb-24 at 04:16Two initial considerations: d3.create("svg")
is rarely used in real D3 codes. Also, you don't have data appended to the DOM, just SVG elements you loaded (unless you're calling that "data").
Back to your question, you don't need path.bounds
to make your code work, actually you don't even need d3.zoom
. All you need is get the element's box (with getBBox
) and do the appropriate transform.
The real problem, though, is that you need to wrap all the elements in a , because you cannot apply the transform to the root SVG in SVG 1.1 (apparently this is possible in SVG 2).
Here is a basic demo. In this demo I'm using an external SVG made with different elements (circle, rectangle, text...), which represents the SVG you're appending. You get this SVG with:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install subwayMap
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page