You should draw the lines based on data. That's the whole point of D3 (and it's usually faster).
I'm not sure how you draw the chart, there's no relevant code in the question, but...
If you were able to display individual stacks (I'm assuming you want to display lines on top of stacks, which are collections of rectangles), then you should have no problem displaying lines on top of them.
Without looking at your data, I can only guess... but here's the basic algorithm:
- Iterate over the number of stacks
- Calculate the sum of values of individual elements within each stack
- Draw lines with
yvalues at those sums (scaled with your chart's
- How to add a line at top of stacked bar chart with d3.js?
- How to line up x axis on stacked bar chart with a line overlay in d3.js
- D3 How to add rounded top border to a stacked bar chart
- How to add a line on x-axis on a horizontal bar chart in d3
- D3 : How to add labels top of in each bar in grouped bar chart
- how to create a stacked bar chart with images in d3
- How to create a % difference arrow line with value in a bar chart using D3.js
- How to add live data to stacked bar chart
- Angular-NVD3 Stacked Bar Chart With Line
- How to display total count on top of the stacked bar chart
- How to add tooltip with eclipse in legend in line chart in D3.js
- D3.js - How to add the general update pattern to a stacked bar chart
- How to build stacked bar chart overlapping with d3js
- How to add a properly scaled y axis to a stacked d3 bar chart
- How to update d3.js bar chart with new data
- How to create stacked row chart with one row with dc.js?
- d3.js How to add lines to a bar chart
- d3.js bar chart sorting: can't figure out how to sort x-axis labels along with bars
- How to add a fixed range vertical line to a D3.js chart
- How to use x and width in a bar chart with scaleTime?
- How to add space between bars in a grouped bar chart in a nvd3 grouped multibar chart?
- d3.js stacked bar chart with positive and negative values
- How do I add an "average" line to an nvd3.js Stacked Area Chart?
- How to Make a bar chart with rounded corners with extended grid in d3.js?
- How to modify axis labels in d3 for a stacked bar chart when the axis labels are mapped as part of the scale's domain
- How to create Stacked Line Chart D3, Multiple Y Axis and common X Axis
- NVD3.js: Stacked and grouped bar chart with two y-axis
- D3 - How to loop through an object with keys for a bar chart
- NVD3 Stacked Bar Chart Plus Line Overlapped
- d3.js Stacked bar chart with Logarithmic Scaling
More Query from same tag
- Adding more circles to SVG degrades performance drastically
- Use D3 to create a contour/polar graph
- how to put dynamic data text inside rectangle in d3
- Adding links to D3 axis labels
- position tick to overlap axis in d3
- Does it matter which term I pass to d3.selectAll() during a data join, if whatever I append seems to rely solely on the .append() call?
- D3js: Automatic labels placement to avoid overlaps? (force repulsion)
- Arrays not equal
- Creating animation to the D3 and SVG elements
- Show chart images outside of bar when they don't fit inside
- How to create one group with multiple dimension on dc.js
- How to increase the width of a particular node of a hierarchy in D3.js?
- How to dynamically set distance length of connected nodes?
- Ignore missing images in SVG with D3 data and enter methods
- Update d3 chart
- d3.js: click equivalent of mouseout
- Some bars are black when trying to use individual colors
- Path in SVG placed in front of the circles in D3 chart, despite the order of append
- Set origin on d3 graph
- c3.js second y axis doesn't scale to data
- Create tree hierarchy from csv in d3.js
- Need help on updating a D3.js wordcloud
- string compare not working in d3.rgb
- Adding child elements to specific nodes in a force-directed graph using d3js
- How to control d3.format with SI-prefix?
- NVD3: Add the 'total' value to stackedAreaChart's interactiveGuideline
- How to make localization on months / days for D3js?
- d3 donut chart transform: translateY
- D3: append circle does not work - must be missing something