From bfd4718b116433495c4309cdb15649a453d82f7f Mon Sep 17 00:00:00 2001 From: Masayuki Tanaka Date: Wed, 19 Feb 2014 22:16:50 +0900 Subject: [PATCH] Fix rotated sub chart with bar chart --- c3.js | 4 ++-- c3.min.js | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/c3.js b/c3.js index 6b20ecf..9b7b978 100644 --- a/c3.js +++ b/c3.js @@ -2049,8 +2049,8 @@ ]; // switch points if axis is rotated, not applicable for sub chart - var indexX = isSub || !__axis_rotated ? 0 : 1; - var indexY = isSub || !__axis_rotated ? 1 : 0; + var indexX = __axis_rotated ? 1 : 0; + var indexY = __axis_rotated ? 0 : 1; var path = 'M ' + points[0][indexX] + ',' + points[0][indexY] + ' ' + 'L' + points[1][indexX] + ',' + points[1][indexY] + ' ' + diff --git a/c3.min.js b/c3.min.js index d84ca23..3e232f2 100644 --- a/c3.min.js +++ b/c3.min.js @@ -48,9 +48,9 @@ function(){var a,c;C(h.data.targets)||(a=d.mouse(this),c=Ic(h.data.targets,a),10 z.domain(mb("y"));Z.domain(mb("y2"));l.select(".x.axis").transition().duration(g?v:0).call(g?ua:J).style("opacity",t?0:1);l.select(".y.axis").transition().duration(g?0:v).call(g?J:ua).style("opacity",t?0:1);l.select(".y2.axis").transition().call(jb).style("opacity",t?0:1);l.select(".x.axis .-axis-x-label").attr("x",q);hb.domain(z.domain());ib.domain(Z.domain());W.style("display","none");l.select("line.xgrid-focus").style("visibility","hidden").attr("y2",s);if(Xc){if("year"===qe)for(b=[],t=ob(),a= t[0].getFullYear(),t=t[1].getFullYear();a<=t;a++)b.push(new Date(a+"-01-01 00:00:00"));else b=m.ticks(10);b=l.select(".xgrids").selectAll(".xgrid").data(b);b.enter().append("line").attr("class","xgrid");b.attr("x1",g?0:function(a){return m(a)-J.tickOffset()}).attr("x2",g?q:function(a){return m(a)-J.tickOffset()}).attr("y1",g?function(a){return m(a)-J.tickOffset()}:u).attr("y2",g?function(a){return m(a)-J.tickOffset()}:s).style("opacity",function(){return+d.select(this).attr(g?"y1":"x1")===(g?s:0)? 0:1});b.exit().remove()}Xb&&(b=l.selectAll(".xgrid-lines"),b.selectAll("line").transition().duration(v).attr("x1",g?0:Ma).attr("x2",g?q:Ma).attr("y1",g?Ma:u).attr("y2",g?Ma:s),b.selectAll("text").attr("x",g?q:0).attr("y",Ma));c&&Yc&&(b=l.select(".ygrids").selectAll(".ygrid").data(z.ticks(10)),b.enter().append("line").attr("class","ygrid"),b.attr("x1",g?z:0).attr("x2",g?z:q).attr("y1",g?0:z).attr("y2",g?s:z),b.exit().remove());c&&Yb&&(c=l.select(".ygrid-lines"),c.selectAll("line").transition().duration(v).attr("x1", -g?Na:0).attr("x2",g?Na:q).attr("y1",g?0:Na).attr("y2",g?s:Na),c.selectAll("text").attr("x",g?0:q).attr("y",Na));c=function(a){var b=ea?n?1.2*J.tickOffset()/n:0:0.6*((g?s:q)*(a?1:ta(U)/ta(m.domain()))/(fb()-1)),c=Sd(b,n,f,!!a),e=Td(!!a),d=Ud(f,!!a),h=a?F:w;return function(f,k){var l=h(f.id)(0),m=d(f,k)||l,l=[[c(f),m],[c(f),e(f)-(l-m)],[c(f)+b,e(f)-(l-m)],[c(f)+b,m]],m=a||!g?0:1,n=a||!g?1:0;return"M "+l[0][m]+","+l[0][n]+" L"+l[1][m]+","+l[1][n]+" L"+l[2][m]+","+l[2][n]+" L"+l[3][m]+","+l[3][n]+" z"}}; -b=l.selectAll(".-bars").selectAll(".-bar").data(Pc);b.enter().append("path").attr("d",c(!1)).style("stroke","none").style("opacity",0).style("fill",function(a){return K(a.id)}).attr("class",Bc);b.transition().duration(v).attr("d",c(!1)).style("opacity",1);b.exit().transition().duration(v).style("opacity",0).remove();l.selectAll(".chart-line").select(".-line").transition().duration(v).attr("d",re);l.selectAll(".-area").transition().duration(v).attr("d",se);b=l.selectAll(".-circles").selectAll(".-circle").data(Vd); -b.enter().append("circle").attr("class",Od).attr("r",Ub);b.transition().duration(v).style("opacity",Qd).attr("cx",g?xa:wa).attr("cy",g?wa:xa);b.exit().remove();l.selectAll(".chart-arc").select(".-arc").style("opacity",function(a){return a===this._current?0:1}).transition().duration(v).attrTween("d",function(a){a=ja(a);if(!a)return function(){return"M 0 0"};var b=d.interpolate(this._current,a);this._current=b(0);return function(a){a=b(a);return Oc(a.data)?kb(a,!0):"M 0 0"}}).style("opacity",1);l.selectAll(".chart-arc").select("text").attr("transform", +g?Na:0).attr("x2",g?Na:q).attr("y1",g?0:Na).attr("y2",g?s:Na),c.selectAll("text").attr("x",g?0:q).attr("y",Na));c=function(a){var b=ea?n?1.2*J.tickOffset()/n:0:0.6*((g?s:q)*(a?1:ta(U)/ta(m.domain()))/(fb()-1)),c=Sd(b,n,f,!!a),e=Td(!!a),d=Ud(f,!!a),h=a?F:w;return function(a,f){var k=h(a.id)(0),l=d(a,f)||k,k=[[c(a),l],[c(a),e(a)-(k-l)],[c(a)+b,e(a)-(k-l)],[c(a)+b,l]],l=g?1:0,m=g?0:1;return"M "+k[0][l]+","+k[0][m]+" L"+k[1][l]+","+k[1][m]+" L"+k[2][l]+","+k[2][m]+" L"+k[3][l]+","+k[3][m]+" z"}};b=l.selectAll(".-bars").selectAll(".-bar").data(Pc); +b.enter().append("path").attr("d",c(!1)).style("stroke","none").style("opacity",0).style("fill",function(a){return K(a.id)}).attr("class",Bc);b.transition().duration(v).attr("d",c(!1)).style("opacity",1);b.exit().transition().duration(v).style("opacity",0).remove();l.selectAll(".chart-line").select(".-line").transition().duration(v).attr("d",re);l.selectAll(".-area").transition().duration(v).attr("d",se);b=l.selectAll(".-circles").selectAll(".-circle").data(Vd);b.enter().append("circle").attr("class", +Od).attr("r",Ub);b.transition().duration(v).style("opacity",Qd).attr("cx",g?xa:wa).attr("cy",g?wa:xa);b.exit().remove();l.selectAll(".chart-arc").select(".-arc").style("opacity",function(a){return a===this._current?0:1}).transition().duration(v).attrTween("d",function(a){a=ja(a);if(!a)return function(){return"M 0 0"};var b=d.interpolate(this._current,a);this._current=b(0);return function(a){a=b(a);return Oc(a.data)?kb(a,!0):"M 0 0"}}).style("opacity",1);l.selectAll(".chart-arc").select("text").attr("transform", Wa).attr("opacity",0).transition().duration(v).text(Xa).attr("opacity",function(a){return Oc(a.data)?1:0});za&&(null!==d.event&&"zoom"===d.event.type&&L.extent(m.orgDomain()).update(),e&&(E.select(".x.axis").transition().duration(g?v:0).call(gb),L.empty()||L.extent(m.orgDomain()).update(),e=E.selectAll(".-bars").selectAll(".-bar").data(Pc),e.enter().append("path").attr("d",c(!0)).style("stroke","none").style("fill",function(a){return K(a.id)}).attr("class",Bc),e.style("opacity",0).transition().duration(v).attr("d", c(!0)).style("opacity",1),e.exit().transition().duration(v).style("opacity",0).remove(),E.selectAll(".-line").transition().duration(v).attr("d",te)));l.selectAll(".selected-circles").filter(function(a){return sb(a)}).selectAll("circle").remove();l.selectAll(".selected-circle").transition().duration(v).attr("cx",g?xa:wa).attr("cy",g?wa:xa);$?(c=l.select(".event-rects").selectAll(".event-rect").data([0]),oe(c.enter()),c.attr("x",0).attr("y",0).attr("width",q).attr("height",s)):(Mb?(p=function(a,b){var c= wc(b),e=b