Browse Source

Fix legend when unload

pull/45/head
Masayuki Tanaka 11 years ago
parent
commit
c68ff7ebd9
  1. 5
      c3.js
  2. 12
      c3.min.js

5
c3.js

@ -2767,10 +2767,7 @@
.remove();
if (__legend_show) {
svg.selectAll('.legend-item' + getTargetSelectorSuffix(targetId))
.transition()
.style("opacity", 0)
.remove();
svg.selectAll('.legend-item' + getTargetSelectorSuffix(targetId)).remove();
updateLegend(c3.data.targets);
}

12
c3.min.js vendored

@ -82,9 +82,9 @@ Sc).y(h?Sc:function(a){return ha(a.id)(a.value)});return function(b){var c=$b(b.
F.scale=function(a){return h?this.y(a):this.x(a)};F.orgScaleExtent=function(){var a=vd?vd:[1,10];return[a[0],Math.max(La()/a[1],a[1])]};F.updateScaleExtent=function(){var a,b;la?(a=Ba(m.orgDomain())/Ba($),b=this.orgScaleExtent(),a=[b[0]*a,b[1]*a]):ma&&(a=[1,1]);return this.scaleExtent(a)};var n,tb,l,G,Ga,X,sb,$,ud,Wb={};k.focus=function(a){var b=n.selectAll(ka(a)),c=b.filter(oc),b=b.filter(pc);k.revert();k.defocus();c.classed("focused",!0).transition().duration(100).style("opacity",1);b.transition().duration(100).style("opacity",
1);E(k.data.targets)&&Bc(a,!0);mc(a)};k.defocus=function(a){var b=n.selectAll(ka(a)),c=b.filter(oc),b=b.filter(pc);k.revert();c.classed("focused",!1).transition().duration(100).style("opacity",0.3);b.transition().duration(100).style("opacity",0.3);E(k.data.targets)&&Sb(a);Me(a)};k.revert=function(a){var b=n.selectAll(ka(a)),c=b.filter(oc),b=b.filter(pc);c.classed("focused",!1).transition().duration(100).style("opacity",1);b.transition().duration(100).style("opacity",1);E(k.data.targets)&&Sb(a);nc()};
k.show=function(a){n.selectAll(ka(a)).transition().style("opacity",1)};k.hide=function(a){n.selectAll(ka(a)).transition().style("opacity",0)};k.unzoom=function(){I.clear().update();w({withUpdateXDomain:!0})};k.load=function(a){"function"!==typeof a.done&&(a.done=function(){});a.xs&&be(a.xs);"categories"in a&&ja&&(Na=a.categories,N.categories(Na));if("cacheIds"in a&&Yd(a.cacheIds))$a(Zd(a.cacheIds),a.done);else if("data"in a)$a(Ra(a.data),a.done);else if("url"in a)e.csv(a.url,function(b,c){$a(Ra(c),
a.done)});else if("rows"in a)$a(Ra(Hc(a.rows)),a.done);else if("columns"in a)$a(Ra(Ic(a.columns)),a.done);else throw Error("url or rows or columns is required.");};k.unload=function(a){k.data.targets=k.data.targets.filter(function(b){return b.id!==a});n.selectAll(ka(a)).transition().style("opacity",0).remove();Ha&&(n.selectAll(".legend-item"+xb(a)).transition().style("opacity",0).remove(),vb(k.data.targets));0<k.data.targets.length&&w({withUpdateOrgXDomain:!0,withUpdateXDomain:!0})};k.selected=function(a){a=
xb(a);return e.merge(l.selectAll(".-shapes"+a).selectAll(".-shape").filter(function(){return e.select(this).classed(pa)}).map(function(a){return a.map(function(a){return a.__data__})}))};k.select=function(a,b,c){na&&l.selectAll(".-shapes").selectAll(".-shape").each(function(d,g){var f="circle"===this.nodeName?gd:se,h="circle"===this.nodeName?Zb:id;0<=b.indexOf(g)?oa(d)&&(xa||x(a)||0<=a.indexOf(d.id))&&f(e.select(this).classed(pa,!0),d,g):y(c)&&c&&h(e.select(this).classed(pa,!1),d,g)})};k.unselect=
function(a,b){na&&l.selectAll(".-shapes").selectAll(".-shape").each(function(c,d){var g="circle"===this.nodeName?Zb:id;(x(b)||0<=b.indexOf(d))&&oa(c)&&(xa||x(a)||0<=a.indexOf(c.id))&&g(e.select(this).classed(pa,!1),c,d)})};k.toLine=function(a){ca(a,"line");w()};k.toSpline=function(a){ca(a,"spline");w()};k.toBar=function(a){ca(a,"bar");w()};k.toScatter=function(a){ca(a,"scatter");w()};k.toArea=function(a){ca(a,"area");w()};k.toAreaSpline=function(a){ca(a,"area-spline");w()};k.toPie=function(a){ca(a,
"pie");V();ga();w({withTransform:!0})};k.toDonut=function(a){ca(a,"donut");V();ga();w({withTransform:!0})};k.groups=function(a){if(x(a))return v;v=a;w();return v};k.regions=function(a){if(x(a))return Q;Q=a;w();return Q};k.regions.add=function(a){if(x(a))return Q;Q=Q.concat(a);w();return Q};k.regions.remove=function(a,b){var c=[].concat(a);b=y(b)?b:{};c.forEach(function(a){var c=z(b.duration)?b.duration:0;n.selectAll("."+a).transition().duration(c).style("fill-opacity",0).remove();Q=Q.filter(function(b){return 0>
b.classes.indexOf(a)})});return Q};k.data.get=function(a){a=k.data.getAsTarget(a);return y(a)?a.values.map(function(a){return a.value}):void 0};k.data.getAsTarget=function(a){var b=nb(function(b){return b.id===a});return 0<b.length?b[0]:void 0};k.resize=function(a){Ja=a?a.width:null;Hb=a?a.height:null;pd()};k.destroy=function(){k.data.targets=void 0;k.data.x={};sb.html("");K.onresize=null};if("url"in R.data)e.csv(R.data.url,function(a,b){dc(b)});else if("rows"in R.data)dc(Hc(R.data.rows));else if("columns"in
R.data)dc(Ic(R.data.columns));else throw Error("url or rows or columns is required.");return k}})(window);
a.done)});else if("rows"in a)$a(Ra(Hc(a.rows)),a.done);else if("columns"in a)$a(Ra(Ic(a.columns)),a.done);else throw Error("url or rows or columns is required.");};k.unload=function(a){k.data.targets=k.data.targets.filter(function(b){return b.id!==a});n.selectAll(ka(a)).transition().style("opacity",0).remove();Ha&&(n.selectAll(".legend-item"+xb(a)).remove(),vb(k.data.targets));0<k.data.targets.length&&w({withUpdateOrgXDomain:!0,withUpdateXDomain:!0})};k.selected=function(a){a=xb(a);return e.merge(l.selectAll(".-shapes"+
a).selectAll(".-shape").filter(function(){return e.select(this).classed(pa)}).map(function(a){return a.map(function(a){return a.__data__})}))};k.select=function(a,b,c){na&&l.selectAll(".-shapes").selectAll(".-shape").each(function(d,g){var f="circle"===this.nodeName?gd:se,h="circle"===this.nodeName?Zb:id;0<=b.indexOf(g)?oa(d)&&(xa||x(a)||0<=a.indexOf(d.id))&&f(e.select(this).classed(pa,!0),d,g):y(c)&&c&&h(e.select(this).classed(pa,!1),d,g)})};k.unselect=function(a,b){na&&l.selectAll(".-shapes").selectAll(".-shape").each(function(c,
d){var g="circle"===this.nodeName?Zb:id;(x(b)||0<=b.indexOf(d))&&oa(c)&&(xa||x(a)||0<=a.indexOf(c.id))&&g(e.select(this).classed(pa,!1),c,d)})};k.toLine=function(a){ca(a,"line");w()};k.toSpline=function(a){ca(a,"spline");w()};k.toBar=function(a){ca(a,"bar");w()};k.toScatter=function(a){ca(a,"scatter");w()};k.toArea=function(a){ca(a,"area");w()};k.toAreaSpline=function(a){ca(a,"area-spline");w()};k.toPie=function(a){ca(a,"pie");V();ga();w({withTransform:!0})};k.toDonut=function(a){ca(a,"donut");V();
ga();w({withTransform:!0})};k.groups=function(a){if(x(a))return v;v=a;w();return v};k.regions=function(a){if(x(a))return Q;Q=a;w();return Q};k.regions.add=function(a){if(x(a))return Q;Q=Q.concat(a);w();return Q};k.regions.remove=function(a,b){var c=[].concat(a);b=y(b)?b:{};c.forEach(function(a){var c=z(b.duration)?b.duration:0;n.selectAll("."+a).transition().duration(c).style("fill-opacity",0).remove();Q=Q.filter(function(b){return 0>b.classes.indexOf(a)})});return Q};k.data.get=function(a){a=k.data.getAsTarget(a);
return y(a)?a.values.map(function(a){return a.value}):void 0};k.data.getAsTarget=function(a){var b=nb(function(b){return b.id===a});return 0<b.length?b[0]:void 0};k.resize=function(a){Ja=a?a.width:null;Hb=a?a.height:null;pd()};k.destroy=function(){k.data.targets=void 0;k.data.x={};sb.html("");K.onresize=null};if("url"in R.data)e.csv(R.data.url,function(a,b){dc(b)});else if("rows"in R.data)dc(Hc(R.data.rows));else if("columns"in R.data)dc(Ic(R.data.columns));else throw Error("url or rows or columns is required.");
return k}})(window);

Loading…
Cancel
Save