I am trying to build a dashboard using d3 and I have my layout built as a responsive grid. I am using d3 to add an svg element to each item in my grid, and when I add the svg element I also add a rect that is positioned and scaled relative to the size of each grid item. The stroke (stroke-width=1) of the rect is always drawn blurry, and the only way to make it crisp is to add 0.5 to the x and y position of the rect.
I understand what anti-aliasing is and how that is fundamentally what is causing the blurry lines. I am trying to understand how/where/why the rects are being placed 0.5 off, or if by default they are placed in-between pixels.
I am using .clientHeight/.clientWidth to set the viewbox of the svg element, and also to set the size of the rect. Both of those variable return integers. I am using 'fr' units to define the grid, and I tried to switch to absolute pixel values, but it did not help.
Thanks a bunch, here's a snippet and a codepen project:
let rect = svg.selectAll('rect').data([null]);
rect.enter().append('rect')
.merge(rect)
.attr('x', 10) // if I make these values '10.5'
.attr('y', 10) // then everything looks crisp...
.attr('width', props.width - 20)
.attr('height', props.height - 20)
.style('fill', 'none')
.style('stroke', '#FFFFFF')
.style('stroke-width', '1')


