score:0
Accepted answer
Your first set of circles gets appended to a group that is translated:
let svg = d3.select('.plot').append("svg")
.attr('class', 'svgPlot')
.attr("width", width + margin.left + margin.right)
.attr("height", height + margin.top + margin.bottom)
.append("g")
.attr("transform","translate(" + margin.left + "," + margin.top + ")");
In this case, the svg
variable refers to a translated group. However, when you later reselect, you actually append to the root SVG element:
let svg = d3.select('.svgPlot');
This is the origin of the difference.
Source: stackoverflow.com
Related Query
- Updating d3 scatterplot, new data points are not in the correct positions
- updating d3 chart with new data, the old data points not removed
- D3 v4 Scatterplot chart data points are not updating on zoom
- Data points and ticks in the scaleBand axis are not aligned
- d3 bar chart labels not getting updated on updating the chart with the new data
- d3 line and area charts not updating with new data array
- the data is changed, but reloading does not fetch new data, D3
- In a d3 scatterplot using data from a csv file, how do i draw lines connecting related points when the mouse is over a point?
- Not all d3 points are showing in correct position on leaflet map
- Scatterplot is not updating the number of circles
- Drawing a line using d3 is not visible when all data items are the same
- d3.js not updating graph with new data
- D3 forceCollide not working properly after updating the underlying data
- How to show the unhighlighted/ not selected data points on scatter plots when using brush/group in dc.js? And is multiple brushes possible in dc.js
- d3: drawing elements correctly but not adding new data to the dom
- plotting the points x and y, the axes y and x are not shown correctly
- Chart not updating with new data with transitions in D3
- d3js: scatterplot zoom. Only axis is zooming not the data
- Understanding D3 data join using the new syntax - Array data is update but DOM not
- In D3, Bar graph's text labels are not updated after the inclusion of additional data
- d3js with angular directive - each click appending new graphics instead of re-draw or updating the data
- D3 labels for horizontal bar chart are stacking over eachother and not in their correct positions
- D3.js not using all of the data points
- The nodes are not changed their positions as the number of ticks in X-axis changed
- D3 v4 graph not updating bars - but appending new axis data
- angular nvd3 xAxisTickFormatFunction updating the data which I do not want
- nvd3.js : unable to bind onClick event with the data points in the svg
- D3 Scatterplot with thousands of data points
- D3 updating graph with new elements create edges with the wrong nodes
- Updating the data of a pack layout from JSON call and redrawing
More Query from same tag
- How to properly load local JSON in D3?
- Move selected element to the end
- Putting images as axis ticks in d3.js
- Constrained d3.js Force display
- How to create semi circle with d3.shape that start at 9pm and ends at 6am
- TypeError: Cannot read property 'childNodes' of undefined angular
- d3 timeline make axis fragmented (color-code) based on time offset
- Change network chart dynamically with d3plus.js
- What's the best way to properly transition the rectangles, back and forth, horizontally, and indefinitely in D3?
- possible to tween d3.geo.circle().angle()
- brush on rotated lines using d3 to create zoom effect
- D3js force layout destroy and reset
- Is it possible to debounce d3.zoom callback?
- How to integrate a json data frame into an html file
- recursively find all children in tree
- Painless method to zoom&pan so that all elements are within drawing area - d3js
- What does binding to Object do in D3.js
- D3 Line Chart not having proper X & Y axis plotting with Labels
- Can you make a property and populate with values on the fly?
- How to animate line graph in D3
- specifying javascript OO "this" object from D3 .on function
- Different node symbols for d3.js force-directed graph
- D3: cannot load json data from database using PHP
- What is "defensive reference" in javascript?
- D3.js transition for set of rectangles
- Line chart color with D3 wrapper
- Issue attaching javascript events using variation on module pattern
- D3 zoomable sunburst not zooming (with data from R)
- D3.js Bullet Graph - how to output ranges / x-axis values in precentage(n%) rather than in values only (n)?
- D3 js set data from data-attribute