score:1
You cannot get this
DOM element from inside the line generator (with or without Angular). The line generator has no access to the element you're appending using it.
The API is clear about that:
When a line is generated, the x accessor will be invoked for each defined element in the input data array, being passed the element d, the index i, and the array data as three arguments. (emphasis mine)
The same, obviously, goes for the y
accessor. So, as you can see, only the data is passed.
Therefore, this
in this case will be simply the window, and there is no parentNode
here.
Look at this demo (as the stack snippet takes a long time to console.log the window object, I'm using only this.name
):
var line = d3.line()
.x(function(d) {
console.log(this.name);
return d;
})
.y(function(d) {
return d;
});
line([1]);
<script src="https://d3js.org/d3.v5.min.js"></script>
Source: stackoverflow.com
Related Query
- How can I get this svg circle to appear above my d3 path and not below?
- Where can I get the .geojson file for India and not separate files for each state/territory or any other distinction?
- How can I get this D3.js HTML element in my AngularJS so that I can manipulate it?
- How can I get a list of tree-ancestors and tree-descendants from this d3.js layout.tree?
- How can I get this globe visualisation(svg) to become responsive to different screen sizes?
- I can not get php produced json data with d3.json
- Can not seem to get examples from D3js working?
- How can I get this chart to render locally? (D3.js)
- D3 can not get this.parentNode
- Why can I get console.log(variable) to give my value but not return variable?
- How can I get this d3 tree chart to work locally?
- d3: axes being scaled/zoomed, not multi-line graph. How can I fix this issue?
- Why Can I not Get D3 Force Directed Graph Link Labels to work
- How can I get the D3.js axis ticks and positions as an array?
- MultiBar chart with nvd3 / d3 only shows labels for every other tick on the x-axis. How can I get them all to show up?
- How can I get numeric values instead of Logarthmic values in D3 axis scale?
- How can I perform this d3.js magic (Grouped Bar Chart) with JSON rather than CSV?
- Accessibility: d3 brush/zoom can get focus and be controlled with keyboard
- Why can't I get the Bounding Box of this d3.js text?
- How can I get "call" to execute for each data element in D3?
- Is d3.json() function can get json object?
- how do i customise the c3.js chart to get like this
- D3.js - How can I add a new line to the text in this Collapsible Tree?
- d3.js: how can I get 'full width' ticks on the y-axis
- d3.event.x does not get the x cursor's position
- How can i get the startAngle and endAngle of each arc in the sunburst example using d3.js?
- How can I get the natural width and height of an svg image element?
- With D3, how can I set attribute ("fill", "none") of axis path and line, but not text (without editing stylesheet)
- I can tween a D3 arc's endAngle, but not it's startAngle. What am I doing wrong?
- d3.csv function can not load data correctly
More Query from same tag
- How to create axisLeft dynamic in D3.js
- D3 Label to draggable circle
- Create Stacked Bar chart for Timeseries X axis using C3.js
- d3.js: chronological time view
- Cannot get D3.js to work inside Svelte component (with Rollup)
- Using div tooltips versus using g tooltips in d3
- Visualizing dataset into d3 contour by converting obervable to notebook to plain JS
- Is it possible to get Angular2 and D3.js working together?
- What do sub-transitions inherit?
- NVD3 legend Show/Hide chart getting scale / zoom feature disabling
- Horizontal Bar chart Bar labels in D3
- Issue with attempting to create a d3 sunburst visualisation
- Adding two javascript visuals to html page
- d3: Adding the min/max/mean lines to an existing linechart
- D3 force layout: How to maintain a given minimum distance between nodes?
- Having issues with flattening some nested data
- callback function inside of controller finishing after ng-options
- How to get a tooltip show up near the pie slice using d3.js?
- Remove current element based on data availability in D3.js
- D3 path fill is giving weird result
- D3 Radar Chart Colors
- How to get updated and rendered value of axis in NVD3.js
- Conditionally build group in d3
- D3 force layout: making pan on drag (zoom) smoother
- Rotating a symbolTriangle shape in D3
- Uniformly-spaced histogram bins with dc.js?
- Chart in d3js not showing up in react app
- Making a drop down menu from csv data in JS
- D3 tooltip off the chart
- How do I create an API or link to my SVG so other websites can show it?