score:1
When creating your legend, you're setting a height of intervalHeight
for each of the legend colour blocks, and you're calculating a y
attribute for where to place each of the legend blocks based on that intervalHeight
, however, you're rounding that calculated y
attribute, which is sometimes making that y
value higher than it should be, resulting in a gap.
To solve this, you could modify your y
to be set to
function(d, i) { return ((intervals.length - 1 - i) * intervalHeight) + legendMargin; }
without the rounding, or a neat solution I found was to make the height just a little bigger to bridge that gap be setting
.attr("height", intervalHeight + 1)
This way, the height of each bar is a little bit too tall, but it will be masked by the next one anyway. The only visual difference is that the white gap is no longer there.
score:2
The white lines are comming from the white background, the height of each element is to small or the svg can't render the decimal height and then the background is comes to the front.
You can fix this with (Up-rounding):
.attr("height", Math.ceil(intervalHeight))
Source: stackoverflow.com
Related Query
- How to remove white line in d3.js legnd
- How can I remove a line from the 110m TopoJson world map?
- How to remove axis line overflow in c3js line graph
- How can I remove spurious line on zoomable sunburst?
- How to remove tooltips on line when click button d3.js
- How can I remove regular line jumps?
- How to remove black area below/above metricsgraphs.js line graph?
- How can I remove or replace SVG content?
- How do I remove all children elements from a node and then apply them again with different color and size?
- How to remove an attribute in D3.js?
- How do you remove a handler using a d3.js selector
- How to draw straight line in d3.js (horizontally and vertically)
- How to draw line with arrow using d3.js
- How to customize the color scale in a D3 line chart?
- How to disable some streams by default in a nvd3 Simple Line Chart?
- In d3, how to get the interpolated line data from a SVG line?
- How do you remove the background gridlines in nvd3.js?
- How to draw a line / link between two points on a D3 map based on latitude / longitude?
- How do we change the tick values generated by a linear scale in a d3.js line plot?
- How to fit variable length tick labels on a D3 line chart?
- How to make a dashed line legend with d3.js
- How to change line color in d3js according to axis value?
- How to add horizontal line over y-axis in Plottable.js
- Remove line from line graph in d3.js
- How to show a tooltip with value when mouseover a svg line graph using d3.js?
- How to draw a *simple* line segment with d3.js?
- How to draw logarithmic line charts with nvd3
- How to limit a d3 line-chart from showing the line outside of the range of the axis?
- How can I set the each line color or width in SVG path
- How to append text to a line in d3.js
More Query from same tag
- d3.js - attribute d: Expected number
- d3.js equivalent to $(this)
- Display all stacked area data in popup on mouseover in d3.js
- How do I get data from a rectangle in D3?
- Looping a Json object in map.arc()
- Calculate Max of Sum Product of D3 array
- d3.js node translation does not work when changed the node to image
- How to snap svg element to grid while dragging in force layout
- D3 stacked bar chart not able to see full x axis lables
- D3 Code Is Creating 2 SVG elements in the div
- Display a diagram (using d3.js)
- Remove Duplicates from D3js Dropdown
- Creating SVG elements without rendering them
- translating a d3 tooltip with i18next
- Selecting last path of svg with d3.js
- How to apply padding between D3 axes and chart?
- d3.js - Timestamp based on year and week
- How do you label nodes and create arrows in D3?
- D3.js nesting and rollup at the same time in v4
- Color scale not working appropriately in D3/JavaScript
- Change a pivot point of the nested svg using d3.js
- Object Oriented d3
- How to fit variable length tick labels on a D3 line chart?
- D3 Categorical Area Chart - Scale Issue
- Making an animating arc in d3 responsive?
- How to make two sets of axis labels in grouped line graph in dimple.js?
- How to fix the " 'd3' was used before it was defined" error
- Add a circle to a d3.js map
- How to modify D3js graph depending on change of value?
- What is the fastest way to get SVG element given a position (x,y)?