I'm building an interactive timeline using D3. Around the SVG canvas I've placed black lines as visual borders. Now in Firefox and Edge the left borderline is invisible when I set its x1
and x2
values to 0, while in Chrome it shows up (see code snippet below). One solution would be to always set them to 1, but then in Chrome, other elements can be visible to the left of this border which is undesirable.
How can I adapt my code to the client browser? This question asks how to detect Chrome but the answers seem rather hacky. Is there a way of using feature detection here?
var svg = d3.select("body").append("svg");
var w = 500, h = 200;
var padding = 50;
svg.attr("width", w)
.attr("height", h);
var leftPadding = 0;
var leftBorderLine = svg.append("line")
.attr("x1", leftPadding)
.attr("x2", leftPadding)
.attr("y1", 0)
.attr("y2", h)
.attr("stroke", "black")
.attr("stroke-width", 1)
.attr("shape-rendering", "crispEdges")
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.4.11/d3.min.js"></script>