score:0
you need to add circles where you have data points. The circles could be small, and grow or change its color on mouse over. You can add circles to your chart with
// Append circles to the chart
var circles = chartBody.selectAll('circle')
.data(data)
.attr('cx', function(d) { return x(d.date); })
.attr('cy', function(d) { return y(d.value); })
.attr('r', 10)
.attr('fill', 'blue');
Draw the points after drawing the path, so they are not hidden by the line. Regards,
score:0
If you are not doing it with animation, then first remove old circles using
d3.selectAll(".dot").remove();
OR
svg.selectAll(".dot").remove();
And redraw it as per your requirement, so your code will be probably as below.
function zoomed(zoomlevel) {
console.log(d3.event.translate);
console.log(d3.event.scale);
svg.select(".x.axis").call(xAxis);
svg.select(".y.axis").call(yAxis);
svg.select(".x.grid")
.call(make_x_axis()
.tickSize(-height, 0, 0)
.tickFormat(""));
svg.select(".y.grid")
.call(make_y_axis()
.tickSize(-width, 0, 0)
.tickFormat(""));
svg.select(".line")
.attr("class", "line")
.attr("d", line);
svg.selectAll(".dot").remove();
svg.selectAll(".dot")
.data(data)
.enter().append("circle")
.attr('cx', function(d) { return x(d.date); })
.attr('cy', function(d) { return y(d.value); })
.attr('r', zoomlevel*10) //zoomlevel can be -2,-1,1,2... except zero
.attr('fill', 'blue');
}
Source: stackoverflow.com
Related Query
- D3 js line chart shows dot on mouse over and mouse out
- Fill same line color in to circle on Multi Line chart when mouse over and remove color from circle when mouse out
- nvd3.js-Line Chart with View Finder: rotate axis labels and show line values when mouse over
- D3 Line chart doesn't return correct value on ticks mouse over
- d3 multi line with mouse over cursor for both y AND x value
- Highlight closest point d3js line and dot chart
- text & mouse over and mouse out value on bar graph in d3.js
- Issue with mouse over and mouse out d3.js
- d3.js change color and size on line graph dot on mouseover
- D3.js - why mouseover and mouse out fired for each child elements?
- D3.JS time-series line chart with real-time data, panning and zooming
- D3.js: Line chart - tooltip and vertical line of hover
- Solid and dashed line in D3 line chart
- How to show and hides nodes when you move the mouse over a node in D3 Javascript
- D3.js combining bar and line chart
- Line chart using ordinal x-axis with d3.js and nvd3.js
- d3 line chart and clip-path
- d3 v4 drag line chart with x and y axes
- The mouse over event is not fired during the drag and drop action in d3.js
- D3.js - Line Graph: Area path goes over x and y axis on zoom
- Error in A Simple D3 Line chart with Legend and Tooltips for D3v 3.5.13
- Multiples with x/y axis and mouseover example - line path shows wrong values
- nvd3 line chart not shown properly. (dots and shaded area)
- D3 Line Chart to display first and last point values
- mouse over event line path d3
- How to create Stacked Line Chart D3, Multiple Y Axis and common X Axis
- tickSizeOuter not equal zero, but just first and last tick of yAxis shows line
- D3 line chart, Expected number shows number and NaN
- D3.js chart brush and Crossfilter.js scales out of sync
- Adding text labels in middle of each bar - stacked bar chart & Mouse Over Events
More Query from same tag
- Invalid value for <circle> attribute r="NaN" in D3 scatterplot code
- d3 js fast event invoking issue
- How to Give the link to button that contains to specific circle
- D3 select specific node by data
- How to change color of line according to threshold values in C3.js/D3.js charts?
- Labels and Dividing Lines in D3
- d3 tickFormat, remove comma as thousands separator
- How can insert order of an enter selection be controlled?
- d3 bar chart with fixed bar width and fixed spacing to align in center axis line
- How to properly use call() in D3 to bind drag behavior?
- Creating a simple D3 bar chart
- D3 JS - Uncaught TypeError: Cannot read property 'length' of undefined - seems related to data issue
- Add multi color gradient for different points in d3.js
- Tooltip fetching incorrect data
- TypeError: Cannot read property 'createElementNS' of undefined
- relocate d3 map to center of screen no matter the device
- D3js forced directed graph animation and reload issue
- d3.js : re-inserting elements during dragstart/mousedown interferes with click events in Chrome and Safari but not Firefox
- Let's make a map tutorial, stuck at projection step
- D3: How can I find the largest length of my text labels?
- D3.js zoom and touch device smoothness
- How can I draw a simplified network plot in D3.js?
- d3.js nested selections
- How to draw from the last radius finish
- Split a string in object property and make new dataset
- How to draw shape on top of other shape
- Can I use index.html and ui.r for my r shiny interface?
- d3.js, add additional data to pre-existing elements
- Load D3 Collapsible Tree with data from variable
- How to fix d3.js chart scaling