score:1
Accepted answer
Here's the implementation:
paths.on('click', function (d) {
var state = d.state.replace(/\s+/g, '_'),
offset = $('svg.state.'+state).offset();
$('html, body').animate({
scrollTop: offset.top, scrollLeft: offset.left
});
});
And of course, included jQuery:
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
Let me know if this helps. :)
Source: stackoverflow.com
Related Query
- How to link from path elements in one svg to a different element of another svg
- How to get reference to SVG (child) elements nested in another SVG element (parent) using D3?
- How to add filter to create single path from one bar to another bar (not in a loop)
- How to make several path elements inherit their stroke from one place?
- How to pass an event from one element to another in d3?
- How do I remove all children elements from a node and then apply them again with different color and size?
- How do you make an SVG element mouse event bubble up through another element?
- How to remove shapes from filled SVG path
- How to create SVG elements of different types based on data?
- How to get projected path definition strings (not SVG elements) from a GeoJSON dataset with D3?
- How can I color one Y-axis line different from the other grid-lines?
- How to add links from CSV file to SVG elements generated with D3?
- How to fix unwanted circle on / break down of SVG path element for Sankey links with d3?
- How do you prevent the interference of MULTIPLE SVG elements (text labels) on mouseover of a different SVG element?
- how to detect mousemove if svg is behind another element
- How do I change color of path element when its value is selected from dropdown
- How do I move an svg node from one group to another?
- How to init d3 svg element from embeded extern svg-file and manipulate it
- How can I get the dom svg element from d3 node data?
- How do you append a svg image to a rect element of another svg image?
- d3.js touch and hold to create a line from one element to another
- How to change properties of elements in a SVG when I mouseover an element of a second SVG using D3
- d3.js: How to deal with svg elements that are being appended on the same position, one on top of the other?
- How to insert text sibling elements for each existing circle element of svg group?
- How can I make 2 different elements in a SVG group have different drag behaviours?
- d3.js- noob- how to bind data to path from external svg by path ID?
- SVG text elements piling on top of one another at the 0,0 position - D3
- Add two different svg element in g element of svg using d3.js from a dataset
- How to get the JSON path from element
- How to create variable number of image or circle elements in an SVG element using a loop in D3 js(v3)
More Query from same tag
- Access to svg from D3 library
- How to use element from defs inside a circle in D3.JS
- Is there any compatibility between HTML canvas and SVG or are they completely separate beasts?
- How to display negative values in a d3 bar chart?
- How to show hh:mm:ss format at y-axis with c3?
- Building a force-directed concentric circle graph with node ordering from inside out in D3.V4
- NVD3 LinePlusBarChart .enableFocus onClick no working
- How to get the selection which is being dragged in d3.js?
- Creating a Custom List Chart in C3.js or D3.js
- d3 - convert strings to actual values
- Data for sunburst charts with d3.hierarchy using D3js v4
- D3.js: Text is not showing inside a circle(They are on the same level of an element-group). How do I bring the text to the front?
- NVD3 - Positioning of xAxis labels not working
- d3.join() enter called instead of update?
- d3.max didn't get the correct value
- Discrete filter for D3 Crossfilter Dimensions
- d3.js : changing axis text label with glyphicon
- Display one day with d3.slider
- D3 components do not update in React
- How can to implement FontAwesome v5 icons in D3js v4 and Angular 4
- How to apply tooltips for dc.js chart after chart is rendered
- D3.js and Knockout Force Diagram API Updates
- How to control the group node distance in Hierarchical Edge Bundling in D3.js
- Updating a bar chart with .update, .enter, and .exit?
- D3 making new, smaller CSV file
- Setting d3 symbol conditionally
- how to obtain a complete clockwise rotation in D3
- event.touches detecting multiple touch events after touch screen spam
- Changing the color of an svg image
- Color svg paths based on position along gradient in D3