score:1
Accepted answer
You'll need to make a few changes to get this to work:
- Make sure your class names are consistent: Change
cities.selectAll(".dot")
tocities.selectAll(".dualLineChart-dot1")
to match with the class attr you assign a few lines later - The y-accessor is
d.temp
, rather thand.values
, so you should have.attr("cy", function(d) { return y(d.temp); })
to get the y-value - Most importantly, you should change the way you get the data for the points. Because the
cities
variable already is an array of data (split up by city), you just need to access it for your points using.data(function(d) { return d.values; })
, instead of using.data(data, function(d) { return d.values; })
Here's the working code:
cities.selectAll(".dualLineChart-dot1") //adding dots
.data(function(d) { return d.values; })
.enter().append("circle")
.attr("class","dualLineChart-dot1")
.attr("cx", function(d) { return x(d.date); })
.attr("cy", function(d) { return y(d.temp); })
.attr("r", 3.5)
.on("mouseover", function(d){
d3.select(this).style("fill", "blue");
})
.on("mouseout", function(){
d3.select(this).style("fill", "white");
});
Source: stackoverflow.com
Related Query
- D3.js: plot dots on the existing line in a multiseries line chart with long formatted data
- D3js: how to plot multiseries line chart with json data
- Multiseries line chart with mouseover tooltip
- How to plot animated line chart using d3 while the data table is required to be updated every 1 second?
- Align lines and dots with x-axis values in line chart
- d3js gantt chart with date/time scale at the top and current day blue line
- How to make the grids of a chart be in line with axes
- Values are not reflecting Dynamically in D3 Bar Chart using. Overlapping occur with the existing Graph.
- plot dots on multiple lines in line chart
- Time in x-axis and data for the y-axis for line chart in d3.js doesn't match/show with what (data) is on JSON
- Tooltip behavior on line chart with Date as the x-axis
- Fit the cumulative percentage line to the sorted histogram output with d3 for a pareto chart histogram
- How to render multi line chart with DC.js with the following type of data - JAVASCRIPT (DC.js)
- Trying to create a line chart with a linear x-axis, like the time axis, but with numerical data, in DimpleJS
- d3js - How to update an existing svg path in a simple d3 line chart with new data flowing through?
- D3.js line chart - positioning the dots
- Real time data graphing on a line chart with the help of rickshaw and d3.js
- Normalize the Graph axes in NVD3 Line with focus chart
- 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?
- nvd3 line chart with string values on x-axis
- D3.JS time-series line chart with real-time data, panning and zooming
- NVD3 line chart with realtime data
- How to update the fill color on existing svg elements with d3.js?
- javascript charting - nvd3 line chart with two Y-axis
- Make simple bar chart using C3 with separate columns on the x axis
- d3 Line Chart with enter-update-exit logic
- Draw a vertical line representing the current date in d3 gantt chart
- NVD3 line chart with vertical line
- nvd3.js-Line Chart with View Finder: rotate axis labels and show line values when mouse over
- dc.js line chart with range of colors
More Query from same tag
- How do I set the large-arc or sweep flag in d3.svg.arc()
- Using Rickshaw/D3 in Node.js,for server side, raw svg accessible?
- How do I get data from a rectangle in D3?
- d3.js bar chart animations
- "Live" graph d3.js with simulated data
- Stacked bar chart reversed
- Adding text to rectangle elements using D3 / SVG
- Why text append outside svg element d3js?
- how to set button and rect for particular columns in table using d3?
- D3.js - old links not getting deleted after adding a new node and trasitioning
- Crossfilter group a filtered dimension
- How to show surrounding parents in d3 treemap?
- get specific word on click event for SVG Text element
- Unexpected brush filtering behaviour
- Problems with d3.scale.ordinal
- How to draw dots in the coordinates of slices in a d3 pie chart?
- dc.js : how to change circle color on mouseover
- dc charts change legend order
- How can I handle data filtering on a button click on D3.js?
- D3.JS SVG Rectangles don't appear
- PubNub Twitter Data Stream setup doesn't return data
- Populating a Javascript array using MYSQL and JSP
- Javascript comparing dates - bug in d3.js chart
- d3.js: Get data out of synchronous brush selection
- Javascript color gradient even split, blue to grey to red
- d3js - How to insert things in order?
- D3, Flask, Pythonanywhere, problems with csv files
- D3.JS treemap inconsistent zoom behavior
- how to properly read a csv file with not standard encoding in d3.js
- SVG: positioning RECT based on value