From a6e139ed93d256f375cd6898f053b5349c415c33 Mon Sep 17 00:00:00 2001 From: Masayuki Tanaka Date: Fri, 25 Oct 2013 11:41:08 +0700 Subject: [PATCH] Fix extent clip --- c3.js | 1 + c3.min.js | 110 +++++++++++++++++++++++++++--------------------------- 2 files changed, 56 insertions(+), 55 deletions(-) diff --git a/c3.js b/c3.js index 261a27c..2e5f727 100644 --- a/c3.js +++ b/c3.js @@ -1211,6 +1211,7 @@ // Add extent rect for Brush context.append("g") + .attr("clip-path", clipPath) .attr("class", "x brush") .call(brush) .selectAll("rect") diff --git a/c3.min.js b/c3.min.js index 006a2b0..2d58344 100644 --- a/c3.min.js +++ b/c3.min.js @@ -1,64 +1,64 @@ -(function(vb){function wb(){function k(c,$a){c.attr("transform",function(c){return"translate("+($a(c)+U)+",0)"})}function s(c,k){c.attr("transform",function(c){return"translate(0,"+k(c)+")"})}function Ka(c){var k=c[0];c=c[c.length-1];return kv[d].indexOf(c.id)))for(e=0;ev[d].indexOf(c.id)))for(e=0;e=h;h+=diffx2)q+=c(a[g-1],a[g],h,t);return q}function lb(a){var b=l.data.targets=O(a),d,c;m.domain(d3.extent(a.map(function(a){return a.x})));y.domain(D(b,"y"));R.domain(D(b,"y2"));z.domain(m.domain());Na.domain(y.domain());Oa.domain(R.domain());C.ticks(10>a.length?a.length:10);ea.ticks(Cc).outerTickSize(0).tickFormat(Dc);Pa.ticks(Ec).outerTickSize(0).tickFormat(Fc);Jb=m.domain();K.x(z);oa&&Fa.x(m);h.append("g").attr("class", -"x axis").attr("clip-path",f?"":"url(#xaxis-clip)").attr("transform",L.x).call(f?ea:C);h.append("g").attr("class","y axis").attr("clip-path",f?"url(#yaxis-clip)":"").call(f?C:ea).append("text").attr("transform","rotate(-90)").attr("dy","1.4em").attr("dx","-.8em").style("text-anchor","end").text(Gc);Db&&h.append("g").attr("class","y2 axis").attr("transform",L.y2).call(Pa);if(oa)h.append("rect").attr("class","zoom-rect").attr("width",r).attr("height",u).style("opacity",0).call(Fa).on("dblclick.zoom", -null);d=h.append("g").attr("clip-path",Va).attr("class","grid");Zb&&d.append("g").attr("class","xgrids");mb&&(c=d.append("g").attr("class","xgrid-lines").selectAll(".xgrid-line").data(mb).enter().append("g").attr("class","xgrid-line"),c.append("line").attr("class",function(a){return""+a["class"]}),c.append("text").attr("class",function(a){return""+a["class"]}).attr("text-anchor","end").attr("transform",f?"":"rotate(-90)").attr("dx",f?0:-p).attr("dy",-6).text(function(a){return a.text}));Hc&&d.append("g").attr("class", -"xgrid-focus").append("line").attr("class","xgrid-focus").attr("x1",f?0:-10).attr("x2",f?r:-10).attr("y1",f?-10:p).attr("y2",f?-10:u);$b&&d.append("g").attr("class","ygrids");nb&&d.append("g").attr("class","ygrid-lines").selectAll("ygrid-line").data(nb).enter().append("line").attr("class",function(a){return"ygrid-line "+a["class"]});h.append("g").attr("clip-path",Va).attr("class","regions");h.append("g").attr("clip-path",Va).attr("class","chart");h.select(".chart").append("g").attr("class","event-rects").style("fill-opacity", -0).selectAll(".event-rects").data(a).enter().append("rect").attr("class",function(a,b){return"event-rect event-rect-"+b}).style("cursor",function(a){return Z&&ia?"pointer":null}).on("mouseover",function(a,b){if(!Wa){var d=l.data.targets.map(function(a){return La(a.values[b])}),c,e;if(0=h;h+=diffx2)q+=c(a[g-1],a[g],h,t);return q}function lb(a){var b=l.data.targets=O(a),d,c;m.domain(d3.extent(a.map(function(a){return a.x})));y.domain(D(b,"y"));R.domain(D(b,"y2"));z.domain(m.domain());Oa.domain(y.domain());Pa.domain(R.domain());C.ticks(10>a.length?a.length:10);ea.ticks(Cc).outerTickSize(0).tickFormat(Dc);Qa.ticks(Ec).outerTickSize(0).tickFormat(Fc);Jb=m.domain();K.x(z);oa&&Fa.x(m);h.append("g").attr("class", +"x axis").attr("clip-path",f?"":"url(#xaxis-clip)").attr("transform",L.x).call(f?ea:C);h.append("g").attr("class","y axis").attr("clip-path",f?"url(#yaxis-clip)":"").call(f?C:ea).append("text").attr("transform","rotate(-90)").attr("dy","1.4em").attr("dx","-.8em").style("text-anchor","end").text(Gc);Db&&h.append("g").attr("class","y2 axis").attr("transform",L.y2).call(Qa);if(oa)h.append("rect").attr("class","zoom-rect").attr("width",r).attr("height",u).style("opacity",0).call(Fa).on("dblclick.zoom", +null);d=h.append("g").attr("clip-path",Ga).attr("class","grid");Zb&&d.append("g").attr("class","xgrids");mb&&(c=d.append("g").attr("class","xgrid-lines").selectAll(".xgrid-line").data(mb).enter().append("g").attr("class","xgrid-line"),c.append("line").attr("class",function(a){return""+a["class"]}),c.append("text").attr("class",function(a){return""+a["class"]}).attr("text-anchor","end").attr("transform",f?"":"rotate(-90)").attr("dx",f?0:-p).attr("dy",-6).text(function(a){return a.text}));Hc&&d.append("g").attr("class", +"xgrid-focus").append("line").attr("class","xgrid-focus").attr("x1",f?0:-10).attr("x2",f?r:-10).attr("y1",f?-10:p).attr("y2",f?-10:u);$b&&d.append("g").attr("class","ygrids");nb&&d.append("g").attr("class","ygrid-lines").selectAll("ygrid-line").data(nb).enter().append("line").attr("class",function(a){return"ygrid-line "+a["class"]});h.append("g").attr("clip-path",Ga).attr("class","regions");h.append("g").attr("clip-path",Ga).attr("class","chart");h.select(".chart").append("g").attr("class","event-rects").style("fill-opacity", +0).selectAll(".event-rects").data(a).enter().append("rect").attr("class",function(a,b){return"event-rect event-rect-"+b}).style("cursor",function(a){return Z&&ia?"pointer":null}).on("mouseover",function(a,b){if(!Wa){var d=l.data.targets.map(function(a){return Ma(a.values[b])}),c,e;if(0",c,e,g;for(c=0;c"+g+""+e+"";return b+""}),Jc=c(["tooltip","init","show"],!1),ra=c(["tooltip","init","x"],0),ec=c(["tooltip","init","position"],{top:"0px",left:"50px"}),tb=ya.replace("#","")+"-clip",Va="url(#"+tb+")",G="timeseries"===hc,ga="categorized"===hc,qb=null,Wa=!1,pb=!1,ca=qa?40:0,Sc=function(a){return function(b){for(var c=a.length-1,e=a[c];!e[1](b);)e= -a[--c];return e[0](b)}}([[d3.time.format("%Y/%-m/%-d"),function(){return!0}],[d3.time.format("%-m/%-d"),function(a){return a.getMonth()}],[d3.time.format("%-m/%-d"),function(a){return 1!=a.getDate()}],[d3.time.format("%-m/%-d"),function(a){return a.getDay()&&1!=a.getDate()}],[d3.time.format("%I %p"),function(a){return a.getHours()}],[d3.time.format("%I:%M"),function(a){return a.getMinutes()}],[d3.time.format(":%S"),function(a){return a.getSeconds()}],[d3.time.format(".%L"),function(a){return a.getMilliseconds()}]]), -ha=d3.time.format(Pc).parse,Ab,Fb,Cb,Ma,Eb,Gb,r,u,da,bb,na,Hb,Ib,eb,fb,m,y,R,z,Na,Oa,C=ga?wb():d3.svg.axis(),ea=d3.svg.axis(),Pa=d3.svg.axis(),fa=ga?wb():d3.svg.axis();Q();U();var L={main:function(){return"translate("+J+","+p+")"},context:function(){return"translate("+I+","+ta+")"},legend:function(){return"translate("+Ka+","+xb+")"},y2:function(){return"translate("+(f?0:r)+","+(f?10:0)+")"},x:function(){return"translate(0,"+u+")"},subx:function(){return"translate(0,"+da+")"}};G&&C.tickFormat(Sc); -ga?(C.categories(Ya).tickCentered(ic),fa.categories(Ya).tickCentered(ic)):(C.tickOffset=function(){return 0},fa.tickOffset=function(){return 0});var Lc=function(){var a=d3.svg.line().x(f?function(a){return E(a.id)(a.value)}:Ua).y(f?Ua:function(a){return E(a.id)(a.value)});return function(b){var c;if(jb(b))return"spline"===Y["string"===typeof b?b:b.id]?a.interpolate("cardinal"):a.interpolate("linear"),0a?0:a},S=function(a,b){var c=[],e=null!==b?b:"#1f77b4 #ff7f0e #2ca02c #d62728 #9467bd #8c564b #e377c2 #7f7f7f #bcbd22 #17becf".split(" "); -return function(b){if(b in a)return a[b];0<=c.indexOf(b)||c.push(b);return e[c.indexOf(b)%e.length]}}(Qc,Rc),Za=d3.select(ya).append("svg").attr("width",r+J+F).attr("height",u+p+V),ub=Za.append("defs");ub.append("clipPath").attr("id",tb).append("rect").attr("y",p).attr("width",r).attr("height",u-p);ub.append("clipPath").attr("id","xaxis-clip").append("rect").attr("x",-1).attr("y",-1).attr("width",r+2).attr("height",40);ub.append("clipPath").attr("id","yaxis-clip").append("rect").attr("x",-J+1).attr("y", -p-1).attr("width",J).attr("height",u-p+2);var h=Za.append("g").attr("transform",L.main),x=null;pa&&(x=Za.append("g").attr("transform",L.context));var sa=null;qa&&(sa=Za.append("g").attr("transform",L.legend));var ja=d3.select(ya).style("position","relative").append("div").style("position","absolute").style("width","30%").style("z-index","10").style("visibility","hidden"),K=d3.svg.brush().on("brush",function(){H({withTransition:!1,withY:!1,withSubchart:!1})}),Fa=d3.behavior.zoom().on("zoom",oa?Nc: -null),Ta=null,gb=null,Jb;l.focus=function(a){l.defocus();d3.selectAll(Ja(a)).filter(function(a){return ab(a.id)}).classed("focused",!0).transition().duration(100).style("opacity",1)};l.defocus=function(a){d3.selectAll(Ja(a)).filter(function(a){return ab(a.id)}).classed("focused",!1).transition().duration(100).style("opacity",0.3)};l.revert=function(a){d3.selectAll(Ja(a)).filter(function(a){return ab(a.id)}).classed("focused",!1).transition().duration(100).style("opacity",1)};l.show=function(a){d3.selectAll(Ja(a)).transition().style("opacity", -1)};l.hide=function(a){d3.selectAll(Ja(a)).transition().style("opacity",0)};l.load=function(a){s(a.done)&&(a.done=function(){});if("cacheIds"in a&&la(a.cacheIds))Ha(ma(a.cacheIds),a.done);else if("data"in a)Ha(O(data),a.done);else if("url"in a)d3.csv(a.url,function(b,c){Ha(O(c),a.done)});else if("rows"in a)Ha(O(ua(a.rows)),a.done);else if("columns"in a)Ha(O(va(a.columns)),a.done);else throw Error("url or rows or columns is required.");};l.unload=function(a){l.data.targets=l.data.targets.filter(function(b){return b.id!= -a});d3.selectAll(".target-"+a).transition().style("opacity",0).remove();qa&&(d3.selectAll(".legend-item-"+a).remove(),Xa(l.data.targets));0b.classes.indexOf(a)})});return M};l.data.get=function(a){a= -l.data.getAsTarget(a);return k(a)?a.values.map(function(a){return a.value}):void 0};l.data.getAsTarget=function(a){var b=Qa(function(b){return b.id==a});return 0",c,e,g;for(c=0;c"+g+""+e+"";return b+""}),Jc=c(["tooltip","init","show"],!1),ra=c(["tooltip","init","x"],0),ec=c(["tooltip","init","position"],{top:"0px",left:"50px"}),tb=ya.replace("#","")+"-clip",Ga="url(#"+tb+")",G="timeseries"===hc,ga="categorized"=== +hc,qb=null,Wa=!1,pb=!1,ca=qa?40:0,Sc=function(a){return function(b){for(var c=a.length-1,e=a[c];!e[1](b);)e=a[--c];return e[0](b)}}([[d3.time.format("%Y/%-m/%-d"),function(){return!0}],[d3.time.format("%-m/%-d"),function(a){return a.getMonth()}],[d3.time.format("%-m/%-d"),function(a){return 1!=a.getDate()}],[d3.time.format("%-m/%-d"),function(a){return a.getDay()&&1!=a.getDate()}],[d3.time.format("%I %p"),function(a){return a.getHours()}],[d3.time.format("%I:%M"),function(a){return a.getMinutes()}], +[d3.time.format(":%S"),function(a){return a.getSeconds()}],[d3.time.format(".%L"),function(a){return a.getMilliseconds()}]]),ha=d3.time.format(Pc).parse,Ab,Fb,Cb,Na,Eb,Gb,r,u,da,bb,na,Hb,Ib,eb,fb,m,y,R,z,Oa,Pa,C=ga?wb():d3.svg.axis(),ea=d3.svg.axis(),Qa=d3.svg.axis(),fa=ga?wb():d3.svg.axis();Q();U();var L={main:function(){return"translate("+J+","+p+")"},context:function(){return"translate("+I+","+ta+")"},legend:function(){return"translate("+La+","+xb+")"},y2:function(){return"translate("+(f?0:r)+ +","+(f?10:0)+")"},x:function(){return"translate(0,"+u+")"},subx:function(){return"translate(0,"+da+")"}};G&&C.tickFormat(Sc);ga?(C.categories(Ya).tickCentered(ic),fa.categories(Ya).tickCentered(ic)):(C.tickOffset=function(){return 0},fa.tickOffset=function(){return 0});var Lc=function(){var a=d3.svg.line().x(f?function(a){return E(a.id)(a.value)}:Va).y(f?Va:function(a){return E(a.id)(a.value)});return function(b){var c;if(jb(b))return"spline"===Y["string"===typeof b?b:b.id]?a.interpolate("cardinal"): +a.interpolate("linear"),0a?0:a},S=function(a,b){var c=[],e=null!==b?b:"#1f77b4 #ff7f0e #2ca02c #d62728 #9467bd #8c564b #e377c2 #7f7f7f #bcbd22 #17becf".split(" ");return function(b){if(b in a)return a[b];0<=c.indexOf(b)||c.push(b);return e[c.indexOf(b)%e.length]}}(Qc,Rc),Za=d3.select(ya).append("svg").attr("width",r+J+F).attr("height",u+p+V),ub=Za.append("defs");ub.append("clipPath").attr("id",tb).append("rect").attr("y",p).attr("width",r).attr("height",u-p);ub.append("clipPath").attr("id","xaxis-clip").append("rect").attr("x", +-1).attr("y",-1).attr("width",r+2).attr("height",40);ub.append("clipPath").attr("id","yaxis-clip").append("rect").attr("x",-J+1).attr("y",p-1).attr("width",J).attr("height",u-p+2);var h=Za.append("g").attr("transform",L.main),x=null;pa&&(x=Za.append("g").attr("transform",L.context));var sa=null;qa&&(sa=Za.append("g").attr("transform",L.legend));var ja=d3.select(ya).style("position","relative").append("div").style("position","absolute").style("width","30%").style("z-index","10").style("visibility", +"hidden"),K=d3.svg.brush().on("brush",function(){H({withTransition:!1,withY:!1,withSubchart:!1})}),Fa=d3.behavior.zoom().on("zoom",oa?Nc:null),Ua=null,gb=null,Jb;l.focus=function(a){l.defocus();d3.selectAll(Ka(a)).filter(function(a){return ab(a.id)}).classed("focused",!0).transition().duration(100).style("opacity",1)};l.defocus=function(a){d3.selectAll(Ka(a)).filter(function(a){return ab(a.id)}).classed("focused",!1).transition().duration(100).style("opacity",0.3)};l.revert=function(a){d3.selectAll(Ka(a)).filter(function(a){return ab(a.id)}).classed("focused", +!1).transition().duration(100).style("opacity",1)};l.show=function(a){d3.selectAll(Ka(a)).transition().style("opacity",1)};l.hide=function(a){d3.selectAll(Ka(a)).transition().style("opacity",0)};l.load=function(a){s(a.done)&&(a.done=function(){});if("cacheIds"in a&&la(a.cacheIds))Ia(ma(a.cacheIds),a.done);else if("data"in a)Ia(O(data),a.done);else if("url"in a)d3.csv(a.url,function(b,c){Ia(O(c),a.done)});else if("rows"in a)Ia(O(ua(a.rows)),a.done);else if("columns"in a)Ia(O(va(a.columns)),a.done); +else throw Error("url or rows or columns is required.");};l.unload=function(a){l.data.targets=l.data.targets.filter(function(b){return b.id!=a});d3.selectAll(".target-"+a).transition().style("opacity",0).remove();qa&&(d3.selectAll(".legend-item-"+a).remove(),Xa(l.data.targets));0b.classes.indexOf(a)})});return M};l.data.get=function(a){a=l.data.getAsTarget(a);return k(a)?a.values.map(function(a){return a.value}):void 0};l.data.getAsTarget=function(a){var b=Ra(function(b){return b.id==a});return 0