score:1
Accepted answer
Why don't you want to use unique element with id for your chart?
var canvas = d3.select("body svg:svg");
if(!svg){
canvas = d3.select("body")
Try to change it to something like
var canvas = d3.select("#yourId svg:svg");
if(!svg){
canvas = d3.select("#yourId")
Also add <div id='yourId'></div>
tag to a tab, where your chart should be
score:0
Try removing svg before rendering another svg
d3.select("svg").remove();
Source: stackoverflow.com
Related Query
- D3 graph generate everytime access to the tab
- How to access the DOM element that correlates to a D3 SVG object?
- How to access the parentNode of a selection to raise an element?
- Is D3.js the right choice for real-time visualization of Neo4j Graph DB data
- semantic zooming of the force directed graph in d3
- Can d3.js draw two scatterplots on the same graph using data from the same source?
- Labels / text on the nodes of a D3 force directed graph
- Adding text to the center of a D3 Donut Graph
- D3 updating graph with new elements create edges with the wrong nodes
- Adding a horizontal line to d3 graph displays at the wrong value
- How do I control the bounce entry of a Force Directed Graph in D3?
- I want to add text on the link in D3.js tree graph
- how do i format the value shown in a d3 graph
- enclosing the nodes of a d3 force directed graph in a circle or a polygon or a cloud
- I want to distinguish the link of d3.js force graph by the thickness
- Adding label to the links in D3 force directed graph
- modifying the d3 force-directed graph example
- What is the equivalent of `link` function in Angular to access DOM elements
- D3: How to dynamically refresh a graph by changing the data file source?
- How to get the same node positions in d3's force layout graph
- nodes without edges escaping the graph in D3 v4
- Tooltip in the network graph is flashing on and off
- How to set the image size in Vis.js network graph
- How to get web element (id) from the element position in D3.js force graph
- How can I get access to the current selection inside a D3 callback?
- How to visualize the graph using d3Network in R
- Trying to retrieve the x-value from a x-coordinate on a d3.js SVG graph
- d3js pie graph from jquery ajax - correlating json keys and values on the chart
- how to generate a network graph with edge weight using D3.js force layout
- How do I access the x- and y-scale of the d3 plot in nvd3?
More Query from same tag
- I am trying to visualize my json object with D3. I want date to be the x axis and y to be sales. number values stored a string
- javascript - placing a rectangle under another element
- d3js svg not visible in chrome
- Setting ticks on a time scale during zoom
- D3 show text for nodes when zoomed
- Appending an element to an existing element in d3.js
- Invalid value for <path> attribute using existing objects
- How to match svg element ids with json keys
- d3 creating path for each object in array, instead of using each objects x and y properties
- parseDate is giving even time value - d3
- Ionic Framework Typescript: Callback function is not able to access `this` variables
- D3 click event redirect to Angular route
- d3 force layout as line (y coordinate stays the same)
- How to add XY coordinate data to a four quadrant scatter-plot using D3?
- Data from local computer
- Letter Spacing on Curves SVG Makes Letters Tilted Using D3
- What is "size" in flare json -- used in D3 examples?
- Is there any possibility of using imported fonts with r2d3?
- d3 how to render 15 circles every line
- Zoomable network graph in AngularJS
- Is an svg element in convex hull (path)?
- Passing data for nvd3 chart from Flask as an argument
- D3.js v4 major & minor tick lines with y-Axis zero as the centered baseline
- D3.js transitions between charts
- D3.js Heatmap: How to read from a nested json and create a Heatmap using D3
- d3.js cinemetrics animation based chart
- 2 D3.js bar charts on the same HTML. One D3 script breaks the other
- D3: display graph in tooltip
- c3js Stacked Bar chart from json array
- D3.js: Load flat 1-dimensional array via d3.csv results in "TypeError: groupData is undefined" / Load multiple CSV files with D3.js