I'm trying to draw some images on background with some color, howewer this method don't work as expected when I zoom out (some part of screen on borders become white). So what is proper method to set background color?
Here is the code:
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<script src="https://d3js.org/d3.v4.min.js"></script>
<style>
body { margin:0;position:fixed;top:0;right:0;bottom:0;left:0; }
</style>
</head>
<body>
<script>
var svg = d3.select("body")
.append("svg")
.attr("width", "100%")
.attr("height", "100%")
.call(d3.zoom().on("zoom", function () {
svg.attr("transform", d3.event.transform)
}))
.append("g")
svg.append("rect")
.attr("width", "100%")
.attr("height", "100%")
.attr("fill", "pink");
svg.append("image")
.attr("xlink:href", "./image/" + "item_1" + ".png")
.attr("x", document.body.clientWidth / 2)
.attr("y", document.body.clientHeight / 2)
.attr("width", 32)
.attr("height", 32)
svg.append("image")
.attr("xlink:href", "./image/" + "item_2" + ".png")
.attr("x", 3 * document.body.clientWidth / 4)
.attr("y", 3 * document.body.clientHeight / 4)
.attr("width", 32)
.attr("height", 32)
</script>
</body>
Update:
Looks like adding background-color
fixed the problem:
...
</style>
</head>
<style>
body{
background-color: #E59400;
}
</style>
<body>
<script>
...