Permalink
Browse files

Prefer style over attr.

  • Loading branch information...
mbostock committed May 27, 2011
1 parent 7126428 commit 98ef2d185f5b027e888134a063b82ad4846106bb
View
@@ -419,7 +419,7 @@ d3.chart.bullet = function() {
var tickEnter = tick.enter().append("svg:g")
.attr("class", "tick")
.attr("transform", d3_chart_bulletTranslate(x0))
- .attr("opacity", 1e-6);
+ .style("opacity", 1e-6);
tickEnter.append("svg:line")
.attr("y1", height)
@@ -435,13 +435,13 @@ d3.chart.bullet = function() {
tickEnter.transition()
.duration(duration)
.attr("transform", d3_chart_bulletTranslate(x1))
- .attr("opacity", 1);
+ .style("opacity", 1);
// Transition the updating ticks to the new scale, x1.
var tickUpdate = tick.transition()
.duration(duration)
.attr("transform", d3_chart_bulletTranslate(x1))
- .attr("opacity", 1);
+ .style("opacity", 1);
tickUpdate.select("line")
.attr("y1", height)
@@ -454,7 +454,7 @@ d3.chart.bullet = function() {
tick.exit().transition()
.duration(duration)
.attr("transform", d3_chart_bulletTranslate(x1))
- .attr("opacity", 1e-6)
+ .style("opacity", 1e-6)
.remove();
});
d3.timer.flush();
@@ -644,7 +644,7 @@ d3.chart.qq = function() {
var xtickEnter = xtick.enter().append("svg:g")
.attr("class", "x tick")
.attr("transform", function(d) { return "translate(" + x0(d) + "," + height + ")"; })
- .attr("opacity", 1e-6);
+ .style("opacity", 1e-6);
xtickEnter.append("svg:line")
.attr("y1", 0)
@@ -659,19 +659,19 @@ d3.chart.qq = function() {
xtickEnter.transition()
.duration(duration)
.attr("transform", tx)
- .attr("opacity", 1);
+ .style("opacity", 1);
// Transition the updating ticks to the new scale, x1.
xtick.transition()
.duration(duration)
.attr("transform", tx)
- .attr("opacity", 1);
+ .style("opacity", 1);
// Transition the exiting ticks to the new scale, x1.
xtick.exit().transition()
.duration(duration)
.attr("transform", tx)
- .attr("opacity", 1e-6)
+ .style("opacity", 1e-6)
.remove();
// Update ticks.
@@ -683,7 +683,7 @@ d3.chart.qq = function() {
var ytickEnter = ytick.enter().append("svg:g")
.attr("class", "y tick")
.attr("transform", function(d) { return "translate(0," + y0(d) + ")"; })
- .attr("opacity", 1e-6);
+ .style("opacity", 1e-6);
ytickEnter.append("svg:line")
.attr("x1", 0)
@@ -699,19 +699,19 @@ d3.chart.qq = function() {
ytickEnter.transition()
.duration(duration)
.attr("transform", ty)
- .attr("opacity", 1);
+ .style("opacity", 1);
// Transition the updating ticks to the new scale, y1.
ytick.transition()
.duration(duration)
.attr("transform", ty)
- .attr("opacity", 1);
+ .style("opacity", 1);
// Transition the exiting ticks to the new scale, y1.
ytick.exit().transition()
.duration(duration)
.attr("transform", ty)
- .attr("opacity", 1e-6)
+ .style("opacity", 1e-6)
.remove();
});
}
View

Large diffs are not rendered by default.

Oops, something went wrong.
View
2 d3.js
@@ -1,4 +1,4 @@
-(function(){d3 = {version: "1.17.0"}; // semver
+(function(){d3 = {version: "1.17.1"}; // semver
if (!Date.now) Date.now = function() {
return +new Date();
};
View

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -3,7 +3,7 @@
}
.day {
- fill: none;
+ fill: #fff;
stroke: #ccc;
shape-rendering: crispEdges;
}
View
@@ -10,7 +10,7 @@ var vis = d3.select("#chart")
.enter().append("svg:svg")
.attr("width", w)
.attr("height", h + ph * 2)
- .attr("class", "RdGy")
+ .attr("class", "RdYlGn")
.append("svg:g")
.attr("transform", "translate(" + pw + "," + ph + ")");
@@ -25,7 +25,6 @@ vis.selectAll("rect.day")
.attr("x", function(d) { return d.week * z; })
.attr("y", function(d) { return d.day * z; })
.attr("class", "day")
- .attr("fill", "#fff")
.attr("width", z)
.attr("height", z);
@@ -42,7 +42,7 @@ d3.json("us-states.json", function(json) {
+ "scale(" + Math.sqrt(data[+d.id] * 5 || 0) + ")"
+ "translate(" + -x + "," + -y + ")";
})
- .attr("stroke-width", function(d) {
+ .style("stroke-width", function(d) {
return 1 / Math.sqrt(data[+d.id] * 5);
})
.attr("d", path);
View
@@ -29,8 +29,8 @@ svg.append("svg:g")
.selectAll("path")
.data(chord.groups)
.enter().append("svg:path")
- .attr("fill", function(d) { return fill(d.index); })
- .attr("stroke", function(d) { return fill(d.index); })
+ .style("fill", function(d) { return fill(d.index); })
+ .style("stroke", function(d) { return fill(d.index); })
.attr("d", d3.svg.arc().innerRadius(r0).outerRadius(r1))
.on("mouseover", fade(.1))
.on("mouseout", fade(1));
@@ -52,7 +52,7 @@ ticks.append("svg:line")
.attr("y1", 0)
.attr("x2", 5)
.attr("y2", 0)
- .attr("stroke", "#000");
+ .style("stroke", "#000");
ticks.append("svg:text")
.attr("x", 8)
@@ -70,9 +70,9 @@ svg.append("svg:g")
.selectAll("path")
.data(chord.chords)
.enter().append("svg:path")
- .attr("fill", function(d) { return fill(d.target.index); })
+ .style("fill", function(d) { return fill(d.target.index); })
.attr("d", d3.svg.chord().radius(r0))
- .attr("opacity", 1);
+ .style("opacity", 1);
/** Returns an array of tick angles and labels, given a group. */
function groupTicks(d) {
@@ -93,6 +93,6 @@ function fade(opacity) {
return d.source.index != i && d.target.index != i;
})
.transition()
- .attr("opacity", opacity);
+ .style("opacity", opacity);
};
}
View
@@ -33,7 +33,7 @@ var g = vis.selectAll("g")
.enter().append("svg:g");
g.append("svg:path")
- .attr("fill", function(d) { return fill(d.value); })
+ .style("fill", function(d) { return fill(d.value); })
.attr("d", arc);
g.append("svg:text")
@@ -48,7 +48,7 @@ d3.timer(function() {
.data(fields);
g.select("path")
- .attr("fill", function(d) { return fill(d.value); })
+ .style("fill", function(d) { return fill(d.value); })
.attr("d", arc);
g.select("text")
@@ -27,8 +27,8 @@ d3.json("flare.json", function(json) {
.enter().append("svg:path")
.attr("display", function(d) { return d.depth ? null : "none"; }) // hide inner ring
.attr("d", arc)
- .attr("stroke", "#fff")
- .attr("fill", function(d) { return color((d.children ? d : d.parent).data.key); })
+ .style("stroke", "#fff")
+ .style("fill", function(d) { return color((d.children ? d : d.parent).data.key); })
.attr("fill-rule", "evenodd");
d3.select("#size").on("click", function() {
View
@@ -64,9 +64,9 @@ d3.json("flowers.json", function(flower) {
.attr("y", padding / 2)
.attr("width", size - padding)
.attr("height", size - padding)
- .attr("fill", "none")
- .attr("stroke", "#aaa")
- .attr("stroke-width", 1.5)
+ .style("fill", "none")
+ .style("stroke", "#aaa")
+ .style("stroke-width", 1.5)
.attr("pointer-events", "all")
.on("mousedown", mousedown);
@@ -77,8 +77,8 @@ d3.json("flowers.json", function(flower) {
.attr("cx", function(d) { return position[d.x.x](d.y[d.x.x]); })
.attr("cy", function(d) { return size - position[d.x.y](d.y[d.x.y]); })
.attr("r", 3)
- .attr("fill", function(d) { return color(d.y.species); })
- .attr("fill-opacity", .5)
+ .style("fill", function(d) { return color(d.y.species); })
+ .style("fill-opacity", .5)
.attr("pointer-events", "none");
d3.select(window)
@@ -93,8 +93,8 @@ d3.json("flowers.json", function(flower) {
rect = d3.select(this.parentNode)
.append("svg:rect")
- .attr("fill", "#999")
- .attr("fill-opacity", .5);
+ .style("fill", "#999")
+ .style("fill-opacity", .5);
d3.event.preventDefault();
}
@@ -127,7 +127,7 @@ d3.json("flowers.json", function(flower) {
count = 0;
svg.selectAll("circle")
- .attr("fill", function(d) {
+ .style("fill", function(d) {
return mins <= d.y[v.x] && maxs >= d.y[v.x]
&& mint <= d.y[v.y] && maxt >= d.y[v.y]
? (count++, color(d.y.species))
@@ -141,7 +141,7 @@ d3.json("flowers.json", function(flower) {
rect = null;
if (!count) svg.selectAll("circle")
- .attr("fill", function(d) {
+ .style("fill", function(d) {
return color(d.y.species);
});
}
View
@@ -30,7 +30,7 @@ var vis = d3.select("#chart")
var layers = vis.selectAll("g.layer")
.data(data)
.enter().append("svg:g")
- .attr("fill", function(d, i) { return color(i / (n - 1)); })
+ .style("fill", function(d, i) { return color(i / (n - 1)); })
.attr("class", "layer");
var bars = layers.selectAll("g.bar")
@@ -26,7 +26,7 @@ var vis = d3.select("#chart")
vis.selectAll("path")
.data(data0)
.enter().append("svg:path")
- .attr("fill", function() { return color(Math.random()); })
+ .style("fill", function() { return color(Math.random()); })
.attr("d", area);
function transition() {
View
@@ -121,7 +121,7 @@ d3.chart.bullet = function() {
var tickEnter = tick.enter().append("svg:g")
.attr("class", "tick")
.attr("transform", d3_chart_bulletTranslate(x0))
- .attr("opacity", 1e-6);
+ .style("opacity", 1e-6);
tickEnter.append("svg:line")
.attr("y1", height)
@@ -137,13 +137,13 @@ d3.chart.bullet = function() {
tickEnter.transition()
.duration(duration)
.attr("transform", d3_chart_bulletTranslate(x1))
- .attr("opacity", 1);
+ .style("opacity", 1);
// Transition the updating ticks to the new scale, x1.
var tickUpdate = tick.transition()
.duration(duration)
.attr("transform", d3_chart_bulletTranslate(x1))
- .attr("opacity", 1);
+ .style("opacity", 1);
tickUpdate.select("line")
.attr("y1", height)
@@ -156,7 +156,7 @@ d3.chart.bullet = function() {
tick.exit().transition()
.duration(duration)
.attr("transform", d3_chart_bulletTranslate(x1))
- .attr("opacity", 1e-6)
+ .style("opacity", 1e-6)
.remove();
});
d3.timer.flush();
View
@@ -105,7 +105,7 @@ d3.chart.qq = function() {
var xtickEnter = xtick.enter().append("svg:g")
.attr("class", "x tick")
.attr("transform", function(d) { return "translate(" + x0(d) + "," + height + ")"; })
- .attr("opacity", 1e-6);
+ .style("opacity", 1e-6);
xtickEnter.append("svg:line")
.attr("y1", 0)
@@ -120,19 +120,19 @@ d3.chart.qq = function() {
xtickEnter.transition()
.duration(duration)
.attr("transform", tx)
- .attr("opacity", 1);
+ .style("opacity", 1);
// Transition the updating ticks to the new scale, x1.
xtick.transition()
.duration(duration)
.attr("transform", tx)
- .attr("opacity", 1);
+ .style("opacity", 1);
// Transition the exiting ticks to the new scale, x1.
xtick.exit().transition()
.duration(duration)
.attr("transform", tx)
- .attr("opacity", 1e-6)
+ .style("opacity", 1e-6)
.remove();
// Update ticks.
@@ -144,7 +144,7 @@ d3.chart.qq = function() {
var ytickEnter = ytick.enter().append("svg:g")
.attr("class", "y tick")
.attr("transform", function(d) { return "translate(0," + y0(d) + ")"; })
- .attr("opacity", 1e-6);
+ .style("opacity", 1e-6);
ytickEnter.append("svg:line")
.attr("x1", 0)
@@ -160,19 +160,19 @@ d3.chart.qq = function() {
ytickEnter.transition()
.duration(duration)
.attr("transform", ty)
- .attr("opacity", 1);
+ .style("opacity", 1);
// Transition the updating ticks to the new scale, y1.
ytick.transition()
.duration(duration)
.attr("transform", ty)
- .attr("opacity", 1);
+ .style("opacity", 1);
// Transition the exiting ticks to the new scale, y1.
ytick.exit().transition()
.duration(duration)
.attr("transform", ty)
- .attr("opacity", 1e-6)
+ .style("opacity", 1e-6)
.remove();
});
}
View
@@ -1 +1 @@
-d3 = {version: "1.17.0"}; // semver
+d3 = {version: "1.17.1"}; // semver

0 comments on commit 98ef2d1

Please sign in to comment.