Advertisement
Guest User

Untitled

a guest
Mar 25th, 2019
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.34 KB | None | 0 0
  1. function draw() {
  2.  
  3. ...
  4. // Add a clipPath: everything out of this area won't be drawn.
  5. var clip = svg.append("defs").append("svg:clipPath")
  6. .attr("id", "clip")
  7. .append("svg:rect")
  8. .attr("width", width )
  9. .attr("height", height )
  10. .attr("x", 0)
  11. .attr("y", 0);
  12. // 針對K線圖的,讓他不會蓋到成交量bar chart
  13. var candlestickClip = svg.append("defs").append("svg:clipPath")
  14. .attr("id", "candlestickClip")
  15. .append("svg:rect")
  16. .attr("width", width )
  17. .attr("height", height - 60 )
  18. .attr("x", 0)
  19. .attr("y", 0);
  20.  
  21. var chart = svg.selectAll("volumeBar") // 畫成交量bar chart
  22. .append("g")
  23. .data(volumeData)
  24. .enter().append("g")
  25. .attr("clip-path", "url(#clip)"); // 加上此attribute
  26. //畫K線圖
  27. var state = svg.selectAll("g.candlestick")
  28. .attr("clip-path", "url(#candlestickClip)") // 加上此attribute
  29.  
  30.  
  31. svg.select("g.sma.ma-0").attr("clip-path", "url(#candlestickClip)").datum(techan.indicator.sma().period(10)(data)).call(sma0);
  32. svg.select("g.sma.ma-1").attr("clip-path", "url(#candlestickClip)").datum(techan.indicator.sma().period(20)(data)).call(sma0);
  33. svg.select("g.ema.ma-2").attr("clip-path", "url(#candlestickClip)").datum(techan.indicator.sma().period(50)(data)).call(sma0);
  34.  
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement