score:0
You are not binding the new data to your rect
in updateData
https://bost.ocks.org/mike/selection/#data
Perhaps surprisingly, data is not a property of the selection, but a property of its elements. This means that when you bind data to a selection, the data is stored in the DOM rather than in the selection: data is assigned to the data property of each element. If an element lacks this property, the associated datum is undefined. Data is therefore persistent while selections can be considered transient: you can reselect elements from the DOM and they will retain whatever data was previously bound to them.
The correct method is :
var updateData = function (newData: any) {
svg.selectAll("rect").data(newData).transition().duration(2000)
.attr("height", function (d: any) { return d * 5; })
.attr("data-currentVal", function (d: any) { return d })
.style("fill", function (d) {
if (d3.select(this).attr("data-currentVal") != d) {
return "red";
}
else { return "black"; }
});
console.log("updateData" + 1);
}
Source: stackoverflow.com
Related Query
- D3 Typescript SVG append not working
- Title Attribute not working for an SVG Rect on Safari
- d3.js - mouseover event not working properly on svg group
- D3 - Positioning tooltip on SVG element not working
- D3: Zooming/Panning Line Graph in SVG is not working in Canvas
- d3 basic append example not working
- SVG text element text-anchor="middle" not working in Firefox
- Positioning svg x/y coordinates with css not working with iOS devices?
- svg <a> element not working
- SVG Marker Not Working
- TypeScript D3 v4 import not working
- CSS transform-origin not working for svg in safari
- SVG not working in Firefox 18
- Svg scale() is not working on Edge(Not Edge Chronium)
- Select SVG elements using rectangle select box not working during zoom : d3.js
- Svg semantic zoom not working on SVG in HTML
- zoom/pan with d3.js and svg not working
- D3 append HTML not working in edge browser
- SVG text path not working correctly in IE
- Mouse up event not working properly in SVG
- ng-click not working in D3 generated svg
- Adding image to svg container using d3 not working on FF and Safari
- append not working when called for the second time
- d3.mouse not working properly on transformed SVG
- SVG Sprite Pattern Not Working in D3
- svg filter not working in mozilla firefox after zoom
- Mutiple force layouts in multiple svg in single page not working
- CSS3 - Transform-origin not working on SVG element in d3.js
- Position relative is not working in Safari 11 Dagre-d3 svg
- Some CSS styles not working on SVG
More Query from same tag
- Examples of Scientific Data representation through D3.js
- Import a package as an extension of another package with ES6 syntax
- How to Use D3 elements inside SAPUI5 , when using JS views?
- angular-nvd3 gives various errors saying that d3.scale is undefined
- j query context menu for d3 rect
- Remove empty groups from dc.js graph
- D3 transform scale and translate
- Labels on d3.js time series chart
- How to draw non-scalable text in SVG with Javascript?
- Visualization data inserted in the webpage is not properly indented and not appearing at desired position
- Button to download inpage SVG code as an SVG file?
- combining multiple geojson files w tsv and preserving property with topojson
- Is it possible to append text to a text element in SVG?
- backgroung fill pattern image not export
- Making DOM Reflow/Refresh
- Plot as many circles as histogram values under the histogram line
- Error from d3 library?
- graph the data from a csv file
- Curving a line chart inside a curved arc
- d3 - Elements being obscured despite being drawn last
- How to plot data points on multi-line chart with multiple y axes
- Draggable interactive graphic element using D3
- how to animate and play over time in d3.js?
- d3-time-format : formula to count days until D0
- D3.js Zooming and panning a collapsible tree diagram
- D3 Pie chart arc partitions
- d3 click to center content at position of element or click
- error "Property visual does not exist on type 'typeof barchart'" while creating power BI custom visual
- How to import ES2015 modules functions selectively, but with namespacing?
- NVD3 Stacked Area chart looks weird