Simplify padding.
This commit is contained in:
Родитель
3158645458
Коммит
ce75813d15
|
@ -11,7 +11,6 @@
|
|||
svg {
|
||||
width: 960px;
|
||||
height: 500px;
|
||||
border: solid 1px #ccc;
|
||||
font: 10px sans-serif;
|
||||
shape-rendering: crispEdges;
|
||||
}
|
||||
|
@ -21,11 +20,11 @@ svg {
|
|||
<body>
|
||||
<script type="text/javascript">
|
||||
|
||||
var w = 960,
|
||||
h = 500,
|
||||
p = [20, 50, 30, 20],
|
||||
x = d3.scale.ordinal().rangeRoundBands([0, w - p[1] - p[3]]),
|
||||
y = d3.scale.linear().range([0, h - p[0] - p[2]]),
|
||||
var p = [20, 50, 30, 20],
|
||||
w = 960 - p[1] - p[3],
|
||||
h = 500 - p[0] - p[2],
|
||||
x = d3.scale.ordinal().rangeRoundBands([0, w]),
|
||||
y = d3.scale.linear().range([0, h]),
|
||||
z = d3.scale.ordinal().range(["lightpink", "darkgray", "lightblue"]),
|
||||
parse = d3.time.format("%m/%Y").parse,
|
||||
format = d3.time.format("%b");
|
||||
|
@ -34,7 +33,7 @@ var svg = d3.select("body").append("svg:svg")
|
|||
.attr("width", w)
|
||||
.attr("height", h)
|
||||
.append("svg:g")
|
||||
.attr("transform", "translate(" + p[3] + "," + (h - p[2]) + ")");
|
||||
.attr("transform", "translate(" + p[3] + "," + (h + p[0]) + ")");
|
||||
|
||||
d3.csv("crimea.csv", function(crimea) {
|
||||
|
||||
|
@ -84,12 +83,12 @@ d3.csv("crimea.csv", function(crimea) {
|
|||
.attr("transform", function(d) { return "translate(0," + -y(d) + ")"; });
|
||||
|
||||
rule.append("svg:line")
|
||||
.attr("x2", w - p[1] - p[3])
|
||||
.attr("x2", w)
|
||||
.style("stroke", function(d) { return d ? "#fff" : "#000"; })
|
||||
.style("stroke-opacity", function(d) { return d ? .7 : null; });
|
||||
|
||||
rule.append("svg:text")
|
||||
.attr("x", w - p[1] - p[3] + 6)
|
||||
.attr("x", w + 6)
|
||||
.attr("dy", ".35em")
|
||||
.text(d3.format(",d"));
|
||||
});
|
||||
|
|
Загрузка…
Ссылка в новой задаче