score:1
Accepted answer
In your brushed and zoomed functions, you need to select your circles and apply dynamic attributes. But before you do that, you need to rename the class for your circles. Something like:
// draw dots
focus.selectAll("circle")
.data(data)
.enter().append("circle")
.attr("class", "circle")
...
function brushed() {
if (d3.event.sourceEvent && d3.event.sourceEvent.type === "zoom") return; // ignore brush-by-zoom
var s = d3.event.selection || x2.range();
x.domain(s.map(x2.invert, x2));
focus.select(".area").attr("d", area);
focus.select(".axis--x").call(xAxis);
focus.selectAll(".circle")
.attr("r", (d)=>{return (d.PTS)})
.attr("cx", (d)=>{return x(d.date)})
.attr("cy", (d)=>{return y(d.PTS)})
svg.select(".zoom").call(zoom.transform, d3.zoomIdentity
.scale(width / (s[1] - s[0]))
.translate(-s[0], 0));
}
function zoomed() {
if (d3.event.sourceEvent && d3.event.sourceEvent.type === "brush") return; // ignore zoom-by-brush
var t = d3.event.transform;
x.domain(t.rescaleX(x2).domain());
focus.select(".area").attr("d", area);
focus.select(".axis--x").call(xAxis);
focus.selectAll(".circle")
.attr("r", (d)=>{return (d.PTS)})
.attr("cx", (d)=>{return x(d.date)})
.attr("cy", (d)=>{return y(d.PTS)})
context.select(".brush").call(brush.move, x.range().map(t.invertX, t));
}
Source: stackoverflow.com
Related Query
- Trying to user scatterplots in a d3 chart with brush/zoom
- D3: Unit Bar Chart with Brush and Zoom (transpose)
- how to zoom d3.js chart and reload data with greater granularity (in AJAX)
- Grouped bar chart with zoom and updateable data error
- Trying to use D3 with React to create a bar chart
- D3 Multi-Series Line Chart with ZOOM
- d3 zoom and drag with SVG axes and canvas chart
- d3 bar chart with brush
- How to zoom in chart correctly with multiple y-axis
- Trying to make dynamic D3 Chart with Bar and Difference line/value
- d3.js brush with multiline chart
- Trying to create line chart with Circle Tooltip
- Zoom on brush in horizontal bar chart
- D3js v5 Trying to select multiple bars in bar chart using brush and saving values to variable and table
- Error: <path> attribute d: expected number - when trying to build a line chart with D3
- X axis label not displayed in bar chart with scroll and zoom feature - d3js, Brushing
- D3 zoom behavior with multiple containers for a chart in one svg
- d3js multi-line chart with focus+context zoom
- Calling alternate chart drawing function based on user selection with d3js
- trying to create a donut chart with labels inside the curve using d3.js
- d3.js multi line chart with brush
- d3 using zoom and brush on a bar chart
- Trying to create a line chart with a linear x-axis, like the time axis, but with numerical data, in DimpleJS
- How to zoom via brush in d3 with non-standart axises
- D3 - resizable chart with brush
- Trying to get circles on map to transition into bars in bar chart with D3
- Implementation of brush with x-axis zoom with nvd3
- d3js bar chart with brush slider
- d3 multi line chart with zoom and update
- D3: How to refresh a chart with new data?
More Query from same tag
- How do I make the d3 zoomable treemap responsive?
- How to fix unwanted circle on / break down of SVG path element for Sankey links with d3?
- D3. Can more then one element be associated with a single datum?
- In d3.js geo map how to create a circle over the each country?
- d3js map displays incorrectly in mobile chrome
- D3.js map that automatically updates from google form’s answer sheet
- Invert yAxis using NVD3.js
- How do I animate the path of a line graph via d3?
- Time slider to move automatically using setInterval()
- d3.js save states
- How to generate graphs and charts on the fly using web2py
- Disable zoom on selected elements only
- how to fix weird drag behavior?
- changing svg circles to image
- How to limit d3.svg.axis to integer labels?
- How to access the DOM element that correlates to a D3 SVG object?
- Error: Property 'x' does not exist on type '[number, number]'
- How can I add a background colour behind PNG, when image URL is pulled from my D3.js dataset?
- IBM Cognos Analytics with D3.js Bar Chart height problem
- How to color DC js bubble chart based on column value?
- Why are programmatically inserted SVG <tspan> elements not drawn, except with d3.js?
- How to display parent elements in a nested treemap?
- How to manually convert point features to SVG coordinates
- D3.js rotate axis labels around the middle point
- Prevent svg groups from overlapping (D3 js v4)
- How to add single label per svg element?
- I am trying to get NVD3 to work with data from an ajax request
- Working with JSON and Angular NVD3
- Bind new variables to __data__, keep existing variables
- Properly using D3 `data` method with a function and data set passed