score:1
Accepted answer
You are drawing the lines with two slightly different scales.
var xScale = d3.scale.linear()
.domain([0, d3.max(dataset, function(d) {
return d[0];
})])
.range([padding, w - padding]);
/*y scale*/
var yScale = d3.scale.linear()
.domain([0, d3.max(dataset, function(d) {
return d[1];
})])
.range([h - padding, padding]);
and
/*x scale*/
var xScaleIndividual = d3.scale.linear()
.domain([0, d3.max(datasetIndividual, function(d) {
return d[0];
})])
.range([padding, w - padding]);
/*y scale*/
var yScaleIndividual = d3.scale.linear()
.domain([0, d3.max(datasetIndividual, function(d) {
return d[1];
})])
.range([h - padding, padding]);
This makes the calculations of the position of each line just a tiny bit different and that difference depends on the random difference between the extents of the two data sets.
Passing the same data to both scales (or just using the same scale for both lines) fixes the problem. Here's an updated fiddle with that single change: https://jsfiddle.net/oa0rsvgc/
Source: stackoverflow.com
Related Query
- d3.js multiple line chart rendering: Same dataset but different curve
- D3 line chart same tick on hover gives different values
- placing multiple d3 charts on the same page but applying different styling
- How do you add multiple lines to a D3JS line chart where the depedent variable data sources start at different positions along the range?
- Adding color dynamically to a multiple line chart but it is not working in d3.js
- Use D3.js single line graph to display same date but different temperatures
- How to draw two line on the same xScale but different time frame
- On common x-axis how to draw a chart with different unit of dataset array (multi line chart)
- d3-graphviz: incorrect rendering if I use same graphviz renderer to draw slightly different graph multiple times
- D3 bar chart same values on chart but data different
- D3.js: Multiple line charts mouseover with same x (time) showing different y (price)
- Same color is showing in different arc of d3 pie chart
- How to create Stacked Line Chart D3, Multiple Y Axis and common X Axis
- d3 JSON multiple line chart
- area chart with d3 is not rendering on jsp page but working fine with html
- D3 with AngularJs, Multiple charts on same page with different data based on common key
- Multiple line chart not working with date format
- Multiple line chart append path directly
- want to generate multiple charts in d3 in same page for different data set
- Simplifying a line before rendering on chart in d3
- how to transition a multiseries line chart to a new dataset
- Independent scales for small multiple line chart
- Draw multiple line chart using d3.entries key value pair
- Why doesn't the same group render a correct line chart and corresponding range chart?
- plot dots on multiple lines in line chart
- d3.js Stacked Bar Chart working for one dataset but not the other
- Does D3 support multiple brushes on the same line chart?
- Fill same line color in to circle on Multi Line chart when mouse over and remove color from circle when mouse out
- Fill line chart area with multiple colors
- Multiple series line chart
More Query from same tag
- Adding tooltip to line chart not showing
- filter the json data and draw the nvd3 chart using filtered data
- D3.js V4 Forced Directed Graph Zoom
- Drawing map with d3js from openstreetmap geojson
- Reactsj and d3v4 integration -- Table and Pie chart application with jest testing
- Relationship Graph with D3
- c3js have x axis start from 0 when it has negative value
- Group shapes/counties together by a list of attributes with D3.js
- Zoom on tree layout preserve root node location
- how to get a parentNode's index i using d3.js
- d3 geo - Map projection
- Add hyperlink to d3.js table rows and cells
- D3 adding dots to multiple stacked line charts
- Parent child JSON from CSV using Python sunburst
- Mozilla(Firefox) , Marker , Multiple SVGs
- How do I get my area filled beneath my d3 line chart to be a gradient?
- I'm a bit stuck with array/object manipulation
- d3 getting invert value of Band Scales
- d3 retrieve and add to current selection's attribute value
- D3 changing X Axis on zoom
- D3 Persistent Path d expected number error during transition
- Distinguishing click and double-click in D3 Version 4
- Geojson file not showing up in D3.js
- Family Tree with multiple parents using D3, VX & React
- SVG Marker Not Working
- How to skip or ignore rows above header?
- D3.js and Knockout Force Diagram API Updates
- Are there any alternatives to .append() in D3.js?
- d3 change class of clicked node text
- How to interact with d3.js mouse events from overlapping shapes?