Skip to content

Commit ce75813

Browse files
committed
Simplify padding.
1 parent 3158645 commit ce75813

1 file changed

Lines changed: 8 additions & 9 deletions

File tree

examples/crimea/crimea-stacked-bar.html

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
svg {
1212
width: 960px;
1313
height: 500px;
14-
border: solid 1px #ccc;
1514
font: 10px sans-serif;
1615
shape-rendering: crispEdges;
1716
}
@@ -21,11 +20,11 @@
2120
<body>
2221
<script type="text/javascript">
2322

24-
var w = 960,
25-
h = 500,
26-
p = [20, 50, 30, 20],
27-
x = d3.scale.ordinal().rangeRoundBands([0, w - p[1] - p[3]]),
28-
y = d3.scale.linear().range([0, h - p[0] - p[2]]),
23+
var p = [20, 50, 30, 20],
24+
w = 960 - p[1] - p[3],
25+
h = 500 - p[0] - p[2],
26+
x = d3.scale.ordinal().rangeRoundBands([0, w]),
27+
y = d3.scale.linear().range([0, h]),
2928
z = d3.scale.ordinal().range(["lightpink", "darkgray", "lightblue"]),
3029
parse = d3.time.format("%m/%Y").parse,
3130
format = d3.time.format("%b");
@@ -34,7 +33,7 @@
3433
.attr("width", w)
3534
.attr("height", h)
3635
.append("svg:g")
37-
.attr("transform", "translate(" + p[3] + "," + (h - p[2]) + ")");
36+
.attr("transform", "translate(" + p[3] + "," + (h + p[0]) + ")");
3837

3938
d3.csv("crimea.csv", function(crimea) {
4039

@@ -84,12 +83,12 @@
8483
.attr("transform", function(d) { return "translate(0," + -y(d) + ")"; });
8584

8685
rule.append("svg:line")
87-
.attr("x2", w - p[1] - p[3])
86+
.attr("x2", w)
8887
.style("stroke", function(d) { return d ? "#fff" : "#000"; })
8988
.style("stroke-opacity", function(d) { return d ? .7 : null; });
9089

9190
rule.append("svg:text")
92-
.attr("x", w - p[1] - p[3] + 6)
91+
.attr("x", w + 6)
9392
.attr("dy", ".35em")
9493
.text(d3.format(",d"));
9594
});

0 commit comments

Comments
 (0)