2013-03-06 166 views
0

我已经通过jQuery创建了HTML 5 SVG折线图。请参考下面的截图。使用jQuery的SVG路径动画/ javascript

enter image description here

请参考下面的SVG路径:

<path id="John" clip-path="url(&quot;#ChartAreaClip&quot;)" fill="none" stroke="red" stroke-width="3" d="M 136 213.6 L 202 259.36 M 202 259.36 L 268 222.18 M 268 222.18 L 334 159.26 M 334 159.26 L 400 150.68 M 400 150.68 L 466 79.18 M 466 79.18 L 532 170.7 M 532 170.7 L 598 167.84 M 598 167.84 L 664 99.2"/> 

我要执行的路径动画(即)线是画像运动的影响。像下面的链接

http://www.highcharts.com/demo/

我也提到了下面的链接,但不能得到的想法。

https://developer.mozilla.org/en-US/docs/SVG/Element/animateMotion

https://developer.mozilla.org/en-US/docs/SVG/Element/animateColor

https://developer.mozilla.org/en-US/docs/SVG/Element/animate

可以请你提供任何解决方案,以折线图动画路径? (即)路径动画线图表

谢谢,

希瓦

回答

0

对于这种效果可以定义一个矩形clipPath,动态显示矩形,并使用它的路径的剪辑路径。

像这样:

<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> 
    <defs> 
     <clipPath id="curtainClip"> 
      <rect id="clipRect" x="0" y="0" width="100" height="100"/> 
     </clipPath> 
    </defs> 

    <animate xlink:href="#clipRect" 
     attributeName="width" 
     dur="1s" 
     from="0" 
     to="100" /> 

    <path clip-path="url(#curtainClip)" stroke="red" d="M 0 0 L 100 100"/> 
</svg>