Simplify path handling.
There will always be a single <path> element, so no need to handle enter, update and exit cases. WebKit seems to erroneously warn (in the error console) that it can't parse `d=""`. I can't see anything in the SVG spec disallowing an empty `d` attribute so I think this is safe to ignore.
This commit is contained in:
Родитель
3e72f75f3e
Коммит
1c2546050f
|
@ -28,18 +28,13 @@ var line = d3.svg.line()
|
|||
.x(function(d) { return d[0]; })
|
||||
.y(function(d) { return d[1]; });
|
||||
|
||||
var path = vis.append("svg:path")
|
||||
.data([points])
|
||||
.attr("class", "line");
|
||||
|
||||
function update() {
|
||||
var path = vis.selectAll("path")
|
||||
.data(points.length ? [points] : []);
|
||||
|
||||
path.enter().append("svg:path")
|
||||
.attr("class", "line")
|
||||
.attr("d", line);
|
||||
|
||||
path.attr("d", line);
|
||||
|
||||
path.exit().remove();
|
||||
|
||||
var circle = vis.selectAll("circle")
|
||||
.data(points, function(d) { return d; });
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче