小编Kin*_*Kin的帖子

为什么我的响应式 D3 图表上的某些网格线会随机消失?

我为我的 D3 图表创建了一个精简的JSFiddle。我使用以下解决方案使其具有响应性(使用 viewbox 和 preserveaspectratio): responsive D3 chart

当我调整窗口大小并使其变小时,一些网格线似乎消失并重新出现。我认为这在小分辨率下看起来很糟糕(例如 320x480 手机)。当窗口变小时,有没有办法保留我的网格线?

HTML代码:

<!--//d3 chart//-->
<div class="centre-div"></div>
Run Code Online (Sandbox Code Playgroud)

CSS 代码:

.centre-div {
  margin: 0 auto;
  max-width: 550px;
}

/* D3 chart css */
.axis path,
.axis line {
  fill: none;
  stroke: black;
  shape-rendering: crispEdges;
}

.axis text {
  font-family: sans-serif;
  font-size: 11px;
}
Run Code Online (Sandbox Code Playgroud)

JS代码:

//function createScatterplot() {
//Width and height
var margin = {
  top: 15,
  right: 2,
  bottom: 2,
  left: 2
};
//define width and height as the …
Run Code Online (Sandbox Code Playgroud)

svg pointer-aliasing d3.js responsive

6
推荐指数
1
解决办法
1829
查看次数

标签 统计

d3.js ×1

pointer-aliasing ×1

responsive ×1

svg ×1