score:1
Accepted answer
If you are re-using that same directive for each chart, then in your template your div id isn't unique. This:
var chart = d3.select("#chart").append("div")
will append to the first div with id chart.
Instead, in your link function
find the div from the element
variable.
element.children()
returns the DOM elements in your template.
With your template to find the first child of the outer div should be (untested):
d3.select(element.children(0).children()[0]));
Source: stackoverflow.com
Related Query
- Why Chart is getting appended to the existing div when using ng-repeat?
- Why are my donut charts positioned outside the container when other chart types are correctly positioned?
- Why do the d3 time range functions normalize values when using step?
- div element is getting appended outside the body
- Why the line in this D3 chart isn't properly displayed when updated?
- Maintain color mapping for Stacked/Grouped Multi-Bar Chart using NVD3 when the series count fluxuates
- D3.js line chart using the wrong keys when using general update pattern
- I am getting a strange error when using the "mousover" listener with D3.js. Any ideas?
- Why does D3 not insert elements inside the selected element, when using data().enter()?
- Using D3, I am trying to add and remove lines from a multi line chart when the legend is clicked
- How to find a div using jquery when it is appended using d3.js
- Getting TypeError when trying to sort data within a d3.csv().then() Promise object using a function outside of the then() method
- why Only one line is getting extended while using brushed() in interactive multiseries line chart
- Why isn't d3 text appearing on bar chart when using new dataset?
- Line not visible in line chart when having same value in the domain() - using D3
- Using an ordinal scale ('d3.scale.ordinal') for the x-axis in a bar chart
- Make simple bar chart using C3 with separate columns on the x axis
- Putting an arrow (marker) at specific point on a path when using the d3 javascript library
- why isn't the checkbox change event triggered when i do it programatically in d3js
- Why isn't the C3 Chart appearing?
- Why do the mouseenter/mouseleave events fire when entering/leaving child elements in an SVG?
- Appended text not appearing when using D3
- how to add legend to a pie chart using D3js? And how to centralise the pie chart?
- How to place text on the circle when using D3.js force layout?
- How to plot animated line chart using d3 while the data table is required to be updated every 1 second?
- I'm getting JavaScript error "d.getMonth is not a function" when trying to format a date using d3.time.format
- When using D3.js, is there a method to automatically get the closest `key` that has data?
- d3 bar chart using rangeRoundBands - why is there outer padding?
- How to modify axis labels in d3 for a stacked bar chart when the axis labels are mapped as part of the scale's domain
- D3.js - Highlight chart elements when interacting with the legend & vice versa
More Query from same tag
- svg - get path coordinates of overlapping shape areas
- Property 'value' of undefined or null reference in Javascript/D3.js
- Add text in rect svg and append it to arc in donut chart
- Changing size of ticks on y axis and adding legend in D3.js
- How can I add an external group to an existing svg with d3.js?
- D3 How to filter data from multiple datasets
- how to draw a dated graph using D3.js
- padding top in bar chart
- D3 Multiple SVG Objects Following Path
- Why do transitions flicker/stutter when applied in a separate function (D3)
- html in d3.js text tag
- Javascript chart or graph generation via browser or node server only for existing public solutions?
- Normalize the Graph axes in NVD3 Line with focus chart
- How can I group data to be filtered without losing crossfilter functionality using dc.js?
- dc.js line chart is not showing anything
- What is the correct way to import and use d3 and its submodules in ES6?
- D3 events on path don't work
- Vertically align nvd3 legend
- Time scale axis ticks positions
- D3 set elements to transition in order
- D3 V4 Basic example not working
- Putting an arrow (marker) at specific point on a path when using the d3 javascript library
- Adding links to D3 axis labels
- Bounding box in D3.js
- D3: Accessing bound data after using .datum()
- D3.js data mapping coordinates onto a topojson map
- Customize grid lines in d3 bar chart
- Is it possible to skip nodes in D3.js tree?
- How to set default value to dc selectMenu
- Map D3.js - ogr2ogr installation