score:1
Accepted answer
Here's the working JSFiddle: http://jsfiddle.net/NYEaX/1860/
Where you were appending the horizontal lines, you were using barWidth - 100/(i+1);
to determine the x-axis. This would have worked if barWidth
was actually the width of each bar, (but it had been set to 150 instead?)
.attr("x1", function(d, i) {
return (i * 30);
Each bar has a width of 20
and a margin of 5
on each side. So to calculate the offset, just multipy the bar number, i
by with total width of the bar, 30
.
Source: stackoverflow.com
Related Query
- d3.js water bar chart
- Bar chart with negative values
- Using an ordinal scale ('d3.scale.ordinal') for the x-axis in a bar chart
- How to apply horizontal break to a d3.js bar chart
- D3js - change Vertical bar chart to Horizontal bar chart
- How to update d3.js bar chart with new data
- Maximum width for column in bar chart
- d3 bar chart is upside down
- Adding label on a D3 bar chart
- rangeRoundBands outerPadding in bar chart way too big
- d3 accessing nested data in grouped bar chart
- Make simple bar chart using C3 with separate columns on the x axis
- d3.js - group 2 data values in a stacked bar chart
- Multi-series bar chart in DC-js
- NVD3 force specific width of bar in bar chart
- d3.js How to add lines to a bar chart
- D3.js combining bar and line chart
- D3 update dataset on click and redraw the bar chart
- d3 bar chart selectAll before appending
- d3 bar chart with range selector in x-axis (like dygraphs)
- d3.js bar chart sorting: can't figure out how to sort x-axis labels along with bars
- Hide all text on y axis dc.js bar chart
- How to animate a d3 js v4 bar chart from bottom(x axis) to up?
- d3 bar chart y axis ticks and grid lines above max value
- Text On each bar of a stacked bar chart d3.js
- How to add a line on x-axis on a horizontal bar chart in d3
- Adding Error Bars to Grouped Bar Chart with D3.js
- D3 brushing on grouped bar chart
- Making a grouped bar chart using d3.js
- Making a grouped bar chart when my groups are varied sizes?
More Query from same tag
- crossfilter dimension not rendering the counts
- dc.js: multiple dimension filters
- d3js: Add quantitative dimension to Hierarchical Edge Bundling
- How can I put a country name on the world map?
- JSON data from Django to D3 graph
- How to add needle to gauge?
- c3.js time format in tooltip
- Add horizontal crosshair to d3.js chart
- How do you remove the background gridlines in nvd3.js?
- Drag & zoom D3 V4 charts with Angular 2
- D3 Leaf Nodes - many elements overlaps
- D3 linking and nodes and dynamic data
- How to make GridLines Dashed in D3 without separate css file?
- d3 - y-axis with log scale - ticks getting overlapped
- Add border to svg groups in nested structure
- D3 pan+ zoom constraints
- How do you append <p> tags to a foreign object in D3.JS
- D3 JS - How to display data for each element on mouse over
- D3 Horizontal Stacked Bar Chart with Lines
- Adding style to SVG shape with a conditional statement
- Use static image as a world map in java-script
- Draw bar charts with rounded rectangles in dc.js
- 404 error trying to parse csv with javascript/D3
- pie chart d3.js
- ngClick causes D3 chart to redraw
- Grouping and rollup in d3
- Design Pattern in A-Frame to reuse geometries
- D3 force graph behaviour in Chrome vs IE
- angular.js $apply bottleneck
- Uncaught TypeError: Cannot read property 'y' of undefined in NV D3 StackedLine