d3-flame-graph
Advanced tools
Comparing version 1.0.9 to 1.0.10
@@ -191,9 +191,3 @@ | ||
function hide(d) { | ||
if(!d.data.original) { | ||
d.data.original = value(d); | ||
} | ||
d.data.v = 0; | ||
if (d.data.value) { | ||
delete d.data.value; | ||
} | ||
d.data.hide = true; | ||
if(children(d)) { | ||
@@ -206,5 +200,3 @@ children(d).forEach(hide); | ||
d.data.fade = false; | ||
if(d.data.original) { | ||
d.data.v = d.data.original; | ||
} | ||
d.data.hide = false; | ||
if(children(d)) { | ||
@@ -322,3 +314,3 @@ children(d).forEach(show); | ||
root.sum(function(d) { | ||
if (d.fade || !value(d)) { | ||
if (d.fade || d.hide) { | ||
return 0; | ||
@@ -325,0 +317,0 @@ } |
@@ -1,1 +0,1 @@ | ||
!function(){"use strict";function n(){function t(t){return t.data.n||t.data.name}function n(t){return t.c||t.children}function e(t){return t.v||t.value}function r(t){S&&(S.innerHTML=t)}function i(t){var n=0,e=1,r=0,i=10,a=6;if(t){for(var u=0;u<t.length&&!(u>a);u++)n+=e*(t.charCodeAt(u)%i),r+=e*(i-1),e*=.7;r>0&&(n/=r)}return n}function a(t){var n=0;if(t){var e=t.split("`");e.length>1&&(t=e[e.length-1]),t=t.split("(")[0],n=i(t)}var r=200+Math.round(55*n),a=0+Math.round(230*(1-n)),u=0+Math.round(55*(1-n));return"rgb("+r+","+a+","+u+")"}function u(t){t.data.original||(t.data.original=e(t)),t.data.v=0,t.data.value&&delete t.data.value,n(t)&&n(t).forEach(u)}function o(t){t.data.fade=!1,t.data.original&&(t.data.v=t.data.original),n(t)&&n(t).forEach(o)}function f(t){var n=[];if(t.parent){var e=t.parent.children.indexOf(t);n=t.parent.children.slice(0),n.splice(e,1)}return n}function c(t){var n=f(t);n.forEach(function(t){u(t)}),t.parent&&c(t.parent)}function l(t){t.parent&&(t.parent.data.fade=!0,l(t.parent))}function d(t){D.hide(t),c(t),o(t),l(t),v(),"function"==typeof z&&z(t)}function h(e,r){function i(e){var r=t(e);n(e)&&n(e).forEach(function(t){i(t)}),r.match(a)?(e.highlight=!0,u.push(e)):e.highlight=!1}var a=new RegExp(r),u=[];return i(e),u}function s(t){t.highlight=!1,n(t)&&n(t).forEach(function(t){s(t)})}function g(n,e){return"function"==typeof L?L(n,e):L?d3.ascending(t(n),t(e)):void 0}function p(t){var n=t.descendants();if(H>0){var e=b/(t.x1-t.x0);n=n.filter(function(t){return(t.x1-t.x0)*e>H})}return n}function v(){O.each(function(i){function a(t){return(t.x1-t.x0)*f}var u=d3.scaleLinear().range([0,b]),o=d3.scaleLinear().range([0,M]);L&&i.sort(g),i.sum(function(t){if(t.fade||!e(t))return 0;var r=e(t);if(n(t))for(var i=n(t),a=0;a<i.length;a++)r-=i[a].value;return r}),P(i);var f=b/(i.x1-i.x0),c=p(i),l=d3.select(this).select("svg").selectAll("g").data(c,function(t){return t.id});l.transition().duration(k).ease(C).attr("transform",function(t){return"translate("+u(t.x0)+","+(q?o(t.depth):A-o(t.depth)-M)+")"}),l.select("rect").attr("width",a);var h=l.enter().append("svg:g").attr("transform",function(t){return"translate("+u(t.x0)+","+(q?o(t.depth):A-o(t.depth)-M)+")"});h.append("svg:rect").transition().delay(k/2).attr("width",a),T||h.append("svg:title"),h.append("foreignObject").append("xhtml:div"),l=d3.select(this).select("svg").selectAll("g").data(c,function(t){return t.id}),l.attr("width",a).attr("height",function(t){return M}).attr("name",function(n){return t(n)}).attr("class",function(t){return t.data.fade?"frame fade":"frame"}),l.select("rect").attr("height",function(t){return M}).attr("fill",function(t){return G(t)}),T||l.select("title").text(F),l.select("foreignObject").attr("width",a).attr("height",function(t){return M}).select("div").attr("class","label").style("display",function(t){return a(t)<35?"none":"block"}).transition().delay(k).text(t),l.on("click",d),l.exit().remove(),l.on("mouseover",function(t){T&&D.show(t),r(F(t))}).on("mouseout",function(t){T&&D.hide(t),r("")})})}function m(t,n){n.forEach(function(n){var e=t.find(function(t){return t.name===n.name});e?(e.original?e.original+=n.value:e.value+=n.value,n.children&&(e.children||(e.children=[]),m(e.children,n.children))):t.push(n)})}function y(){return Math.floor(65536*(1+Math.random())).toString(16).substring(1)}function x(t){t.id=y()+"-"+y()+"--"+y()+"-"+y();for(var n=t.c||t.children||[],e=0;e<n.length;e++)x(n[e])}function w(t){var e=d3.hierarchy(t.datum(),function(t){return n(t)});return x(e),O=t.datum(e),arguments.length?(A||(A=(e.height+2)*M),O.each(function(t){E||(E=d3.select(this).append("svg:svg").attr("width",b).attr("height",A).attr("class","partition d3-flame-graph").call(D),E.append("svg:text").attr("class","title").attr("text-anchor","middle").attr("y","25").attr("x",b/2).attr("fill","#808080").text(j))}),void v()):w}var E,b=960,A=null,M=18,O=null,T=!0,j="",k=750,C=d3.easeCubic,L=!1,q=!1,z=null,H=0,S=null,D=d3.tip().direction("s").offset([8,0]).attr("class","d3-flame-graph-tip").html(function(t){return F(t)}),F=function(n){return t(n)+" ("+d3.format(".3f")(100*(n.x1-n.x0),3)+"%, "+e(n)+" samples)"},G=function(n){return n.highlight?"#E600E6":a(t(n))},P=d3.partition();return w.height=function(t){return arguments.length?(A=t,w):A},w.width=function(t){return arguments.length?(b=t,w):b},w.cellHeight=function(t){return arguments.length?(M=t,w):M},w.tooltip=function(t){return arguments.length?("function"==typeof t&&(D=t),T=!!t,w):T},w.title=function(t){return arguments.length?(j=t,w):j},w.transitionDuration=function(t){return arguments.length?(k=t,w):k},w.transitionEase=function(t){return arguments.length?(C=t,w):C},w.sort=function(t){return arguments.length?(L=t,w):L},w.reversed=function(t){return arguments.length?(q=t,w):q},w.label=function(t){return arguments.length?(F=t,w):F},w.search=function(t){var n=[];return O.each(function(e){n=h(e,t),v()}),n},w.clear=function(){O.each(function(t){s(t),v()})},w.zoomTo=function(t){d(t)},w.resetZoom=function(){O.each(function(t){d(t)})},w.onClick=function(t){return arguments.length?(z=t,w):z},w.merge=function(t){var e;O.each(function(r){m([r.data],[t]),e=d3.hierarchy(r.data,function(t){return n(t)}),x(e)}),O=O.datum(e),v()},w.color=function(t){return arguments.length?(G=t,w):G},w.minFrameSize=function(t){return arguments.length?(H=t,w):H},w.details=function(t){return arguments.length?(S=t,w):S},w}Array.prototype.find||Object.defineProperty(Array.prototype,"find",{value:function(t){if(null==this)throw new TypeError('"this" is null or not defined');var n=Object(this),e=n.length>>>0;if("function"!=typeof t)throw new TypeError("predicate must be a function");for(var r=arguments[1],i=0;e>i;){var a=n[i];if(t.call(r,a,i,n))return a;i++}return void 0}}),Array.prototype.filter||(Array.prototype.filter=function(n,e){if("function"!=typeof n||!this)throw new TypeError;var r=this.length>>>0,i=new Array(r),a=0,u=-1;if(void 0===e)for(;++u!==r;)if(u in this)if(n(t[u],u,t))i[a++]=t[u];else for(;++u!==r;)u in this&&n.call(e,t[u],u,t)&&(i[a++]=t[u]);return i.length=a,i}),"undefined"!=typeof module&&"undefined"!=typeof exports&&"undefined"==typeof d3&&(d3=require("d3")),"undefined"!=typeof module&&"undefined"!=typeof exports&&"undefined"==typeof d3.tip&&(d3.tip=require("d3-tip")),"undefined"!=typeof module&&"undefined"!=typeof exports?module.exports=n:d3.flameGraph=n}(); | ||
!function(){"use strict";function n(){function t(t){return t.data.n||t.data.name}function n(t){return t.c||t.children}function e(t){return t.v||t.value}function r(t){S&&(S.innerHTML=t)}function i(t){var n=0,e=1,r=0,i=10,a=6;if(t){for(var u=0;u<t.length&&!(u>a);u++)n+=e*(t.charCodeAt(u)%i),r+=e*(i-1),e*=.7;r>0&&(n/=r)}return n}function a(t){var n=0;if(t){var e=t.split("`");e.length>1&&(t=e[e.length-1]),t=t.split("(")[0],n=i(t)}var r=200+Math.round(55*n),a=0+Math.round(230*(1-n)),u=0+Math.round(55*(1-n));return"rgb("+r+","+a+","+u+")"}function u(t){t.data.hide=!0,n(t)&&n(t).forEach(u)}function o(t){t.data.fade=!1,t.data.hide=!1,n(t)&&n(t).forEach(o)}function f(t){var n=[];if(t.parent){var e=t.parent.children.indexOf(t);n=t.parent.children.slice(0),n.splice(e,1)}return n}function c(t){var n=f(t);n.forEach(function(t){u(t)}),t.parent&&c(t.parent)}function l(t){t.parent&&(t.parent.data.fade=!0,l(t.parent))}function d(t){D.hide(t),c(t),o(t),l(t),m(),"function"==typeof z&&z(t)}function h(e,r){function i(e){var r=t(e);n(e)&&n(e).forEach(function(t){i(t)}),r.match(a)?(e.highlight=!0,u.push(e)):e.highlight=!1}var a=new RegExp(r),u=[];return i(e),u}function s(t){t.highlight=!1,n(t)&&n(t).forEach(function(t){s(t)})}function g(n,e){return"function"==typeof L?L(n,e):L?d3.ascending(t(n),t(e)):void 0}function p(t){var n=t.descendants();if(H>0){var e=b/(t.x1-t.x0);n=n.filter(function(t){return(t.x1-t.x0)*e>H})}return n}function m(){O.each(function(i){function a(t){return(t.x1-t.x0)*f}var u=d3.scaleLinear().range([0,b]),o=d3.scaleLinear().range([0,M]);L&&i.sort(g),i.sum(function(t){if(t.fade||t.hide)return 0;var r=e(t);if(n(t))for(var i=n(t),a=0;a<i.length;a++)r-=i[a].value;return r}),P(i);var f=b/(i.x1-i.x0),c=p(i),l=d3.select(this).select("svg").selectAll("g").data(c,function(t){return t.id});l.transition().duration(k).ease(C).attr("transform",function(t){return"translate("+u(t.x0)+","+(q?o(t.depth):A-o(t.depth)-M)+")"}),l.select("rect").attr("width",a);var h=l.enter().append("svg:g").attr("transform",function(t){return"translate("+u(t.x0)+","+(q?o(t.depth):A-o(t.depth)-M)+")"});h.append("svg:rect").transition().delay(k/2).attr("width",a),T||h.append("svg:title"),h.append("foreignObject").append("xhtml:div"),l=d3.select(this).select("svg").selectAll("g").data(c,function(t){return t.id}),l.attr("width",a).attr("height",function(t){return M}).attr("name",function(n){return t(n)}).attr("class",function(t){return t.data.fade?"frame fade":"frame"}),l.select("rect").attr("height",function(t){return M}).attr("fill",function(t){return G(t)}),T||l.select("title").text(F),l.select("foreignObject").attr("width",a).attr("height",function(t){return M}).select("div").attr("class","label").style("display",function(t){return a(t)<35?"none":"block"}).transition().delay(k).text(t),l.on("click",d),l.exit().remove(),l.on("mouseover",function(t){T&&D.show(t),r(F(t))}).on("mouseout",function(t){T&&D.hide(t),r("")})})}function v(t,n){n.forEach(function(n){var e=t.find(function(t){return t.name===n.name});e?(e.original?e.original+=n.value:e.value+=n.value,n.children&&(e.children||(e.children=[]),v(e.children,n.children))):t.push(n)})}function y(){return Math.floor(65536*(1+Math.random())).toString(16).substring(1)}function x(t){t.id=y()+"-"+y()+"--"+y()+"-"+y();for(var n=t.c||t.children||[],e=0;e<n.length;e++)x(n[e])}function w(t){var e=d3.hierarchy(t.datum(),function(t){return n(t)});return x(e),O=t.datum(e),arguments.length?(A||(A=(e.height+2)*M),O.each(function(t){E||(E=d3.select(this).append("svg:svg").attr("width",b).attr("height",A).attr("class","partition d3-flame-graph").call(D),E.append("svg:text").attr("class","title").attr("text-anchor","middle").attr("y","25").attr("x",b/2).attr("fill","#808080").text(j))}),void m()):w}var E,b=960,A=null,M=18,O=null,T=!0,j="",k=750,C=d3.easeCubic,L=!1,q=!1,z=null,H=0,S=null,D=d3.tip().direction("s").offset([8,0]).attr("class","d3-flame-graph-tip").html(function(t){return F(t)}),F=function(n){return t(n)+" ("+d3.format(".3f")(100*(n.x1-n.x0),3)+"%, "+e(n)+" samples)"},G=function(n){return n.highlight?"#E600E6":a(t(n))},P=d3.partition();return w.height=function(t){return arguments.length?(A=t,w):A},w.width=function(t){return arguments.length?(b=t,w):b},w.cellHeight=function(t){return arguments.length?(M=t,w):M},w.tooltip=function(t){return arguments.length?("function"==typeof t&&(D=t),T=!!t,w):T},w.title=function(t){return arguments.length?(j=t,w):j},w.transitionDuration=function(t){return arguments.length?(k=t,w):k},w.transitionEase=function(t){return arguments.length?(C=t,w):C},w.sort=function(t){return arguments.length?(L=t,w):L},w.reversed=function(t){return arguments.length?(q=t,w):q},w.label=function(t){return arguments.length?(F=t,w):F},w.search=function(t){var n=[];return O.each(function(e){n=h(e,t),m()}),n},w.clear=function(){O.each(function(t){s(t),m()})},w.zoomTo=function(t){d(t)},w.resetZoom=function(){O.each(function(t){d(t)})},w.onClick=function(t){return arguments.length?(z=t,w):z},w.merge=function(t){var e;O.each(function(r){v([r.data],[t]),e=d3.hierarchy(r.data,function(t){return n(t)}),x(e)}),O=O.datum(e),m()},w.color=function(t){return arguments.length?(G=t,w):G},w.minFrameSize=function(t){return arguments.length?(H=t,w):H},w.details=function(t){return arguments.length?(S=t,w):S},w}Array.prototype.find||Object.defineProperty(Array.prototype,"find",{value:function(t){if(null==this)throw new TypeError('"this" is null or not defined');var n=Object(this),e=n.length>>>0;if("function"!=typeof t)throw new TypeError("predicate must be a function");for(var r=arguments[1],i=0;e>i;){var a=n[i];if(t.call(r,a,i,n))return a;i++}return void 0}}),Array.prototype.filter||(Array.prototype.filter=function(n,e){if("function"!=typeof n||!this)throw new TypeError;var r=this.length>>>0,i=new Array(r),a=0,u=-1;if(void 0===e)for(;++u!==r;)if(u in this)if(n(t[u],u,t))i[a++]=t[u];else for(;++u!==r;)u in this&&n.call(e,t[u],u,t)&&(i[a++]=t[u]);return i.length=a,i}),"undefined"!=typeof module&&"undefined"!=typeof exports&&"undefined"==typeof d3&&(d3=require("d3")),"undefined"!=typeof module&&"undefined"!=typeof exports&&"undefined"==typeof d3.tip&&(d3.tip=require("d3-tip")),"undefined"!=typeof module&&"undefined"!=typeof exports?module.exports=n:d3.flameGraph=n}(); |
{ | ||
"name": "d3-flame-graph", | ||
"version": "1.0.9", | ||
"version": "1.0.10", | ||
"description": "A d3.js library to produce flame graphs.", | ||
@@ -5,0 +5,0 @@ "main": "src/d3.flameGraph.js", |
@@ -221,3 +221,3 @@ # d3-flame-graph | ||
If called with no arguments, `onClick` will return the click handler. | ||
If called with no arguments, `details` will return the flameGraph object. | ||
@@ -224,0 +224,0 @@ ## Issues |
@@ -191,9 +191,3 @@ | ||
function hide(d) { | ||
if(!d.data.original) { | ||
d.data.original = value(d); | ||
} | ||
d.data.v = 0; | ||
if (d.data.value) { | ||
delete d.data.value; | ||
} | ||
d.data.hide = true; | ||
if(children(d)) { | ||
@@ -206,5 +200,3 @@ children(d).forEach(hide); | ||
d.data.fade = false; | ||
if(d.data.original) { | ||
d.data.v = d.data.original; | ||
} | ||
d.data.hide = false; | ||
if(children(d)) { | ||
@@ -322,3 +314,3 @@ children(d).forEach(show); | ||
root.sum(function(d) { | ||
if (d.fade || !value(d)) { | ||
if (d.fade || d.hide) { | ||
return 0; | ||
@@ -325,0 +317,0 @@ } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
11401406
11658