最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - D3 transition not working - Stack Overflow

programmeradmin1浏览0评论

I have the following SVG element:

<svg id='svgTest' xmlns="" version="1.1">
  <g id="test">
    <rect height="20" width="50" fill="blue"/>
  </g>
</svg>

I want to add a transition for the blue rectangle. I tried with the following code with D3:

var rect = d3.select("#test");
rect.transition().duration(5000).attr('height',200);

But it doesn't seem to do anything. What's wrong?

I have the following SVG element:

<svg id='svgTest' xmlns="http://www.w3/2000/svg" version="1.1">
  <g id="test">
    <rect height="20" width="50" fill="blue"/>
  </g>
</svg>

I want to add a transition for the blue rectangle. I tried with the following code with D3:

var rect = d3.select("#test");
rect.transition().duration(5000).attr('height',200);

But it doesn't seem to do anything. What's wrong?

Share asked Oct 12, 2012 at 19:50 PLuiPLui 7653 gold badges12 silver badges29 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 7

You need to select the 'rect' element. Try this:

var rect = d3.select("#test rect");

rect.transition().duration(5000).attr('height',200);

If you want to update multiple elements, use d3.selectAll().

发布评论

评论列表(0)

  1. 暂无评论