score:2
Accepted answer
it appears at the top because the 5 is interpreted by the svg as pixel coordinates, so it is at pixel y=5 (svg counts from top to bottom). in your case, the 5 is not in pixel space, but in data space. to convert from the data space to the pixel space you have to use the yscale, the same way you do with the circles on the scatterplot:
var yaveline = function(d) {
return yscale(data[0].yave);
}
this will convert data[0].yave from data to pixel, that is, it will return the pixel that is associated with the data value.
Source: stackoverflow.com
Related Query
- Adding a y axis horizonal line to a D3 scatter chart
- Adding axis to the dynamic line chart in d3
- D3 line chart axis text labels in multi line
- nvd3.js-Line Chart with View Finder: rotate axis labels and show line values when mouse over
- NVD3 Line Chart X Axis Ticks Are Missing
- D3 - adding grid to simple line chart
- custom x axis tooltip for nvd3 scatter chart
- NVD3 line chart display X axis
- How to create Stacked Line Chart D3, Multiple Y Axis and common X Axis
- Dual Y axis line chart in dc.js
- Adding Grid to D3.js Line Chart
- d3.js Adding a vertical line to a line chart at a specific point, by index
- How to line up x axis on stacked bar chart with a line overlay in d3.js
- d3 bar chart with fixed bar width and fixed spacing to align in center axis line
- Line chart not aligned with x axis
- C3.js change label position of Line Chart Y axis to center up of Y axis
- d3 adding circles on the highest and lowest value on line chart
- D3 JS chart is cut off after adding labels for X and Y axis
- how to make the x axis scrollable in a d3 line chart graph
- Formatting nvd3 line chart axis
- Time series line chart is not sync with axis
- Adding hard coded fixed line to d3 bar chart
- Adding a tooltip over different axis where the line goes through in d3
- how to display data from 1st point on words on y axis for line chart in d3.js
- D3 chart Y axis line is not visible in some resolutions
- Line Chart d3 js-- x axis months
- dc/d3 line chart crashing down to 0 on the y axis after filtering
- D3 Multi Line Chart Not Displaying Properly With X Axis Value
- Adding color dynamically to a multiple line chart but it is not working in d3.js
- Adding data label in D3 Line chart (for Power BI)
More Query from same tag
- How to zoom a d3 chart correctly?
- how to create separate bar chart with JSON array set?
- d3.js thickening only one arc
- How to use the filter method with the update pattern?
- Adding second click event listener within a click event listener
- d3 with bootstrap tooltip: titles not working with data updating
- line segmentation in D3.js
- D3 code linking to php file outputs the actual code as text on the web page
- D3 tree layout from json
- reference to angular's function from d3 data enter
- D3.js loses object reference in "on" events
- Constructing a tooltip values of bar from json file
- D3 sort function always passes undefined arguments
- Drawing a line between two y axis in d3js
- D3js graph is not showing
- How do I draw an arrow between two points in d3v4?
- Why is .delay() not iterating properly?
- Dynamically change width of d3.js sankey chart
- Select all instance of a word in a rendered webpage
- How to write two different text in different axis?
- How to overlay a dynamically selected image over a dynamically populated div
- d3 retrieval of a csv file returns Nan in the javascript console
- unable to get d3js tree to display
- D3.js Node specific rectangle image placed in node circle
- Creating a swim lane chart using d3
- Append text or circle in heatmap grid of d3js
- my d3 line chart looks weird, I can't figure out what's wrong
- D3-tip behind graph when in modal
- Centering force-directed graph
- Creating scrollbars with SVG and d3.js