Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function draw() {
- ...
- // Add a clipPath: everything out of this area won't be drawn.
- var clip = svg.append("defs").append("svg:clipPath")
- .attr("id", "clip")
- .append("svg:rect")
- .attr("width", width )
- .attr("height", height )
- .attr("x", 0)
- .attr("y", 0);
- // 針對K線圖的,讓他不會蓋到成交量bar chart
- var candlestickClip = svg.append("defs").append("svg:clipPath")
- .attr("id", "candlestickClip")
- .append("svg:rect")
- .attr("width", width )
- .attr("height", height - 60 )
- .attr("x", 0)
- .attr("y", 0);
- var chart = svg.selectAll("volumeBar") // 畫成交量bar chart
- .append("g")
- .data(volumeData)
- .enter().append("g")
- .attr("clip-path", "url(#clip)"); // 加上此attribute
- //畫K線圖
- var state = svg.selectAll("g.candlestick")
- .attr("clip-path", "url(#candlestickClip)") // 加上此attribute
- svg.select("g.sma.ma-0").attr("clip-path", "url(#candlestickClip)").datum(techan.indicator.sma().period(10)(data)).call(sma0);
- svg.select("g.sma.ma-1").attr("clip-path", "url(#candlestickClip)").datum(techan.indicator.sma().period(20)(data)).call(sma0);
- svg.select("g.ema.ma-2").attr("clip-path", "url(#candlestickClip)").datum(techan.indicator.sma().period(50)(data)).call(sma0);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement