d3-flame-graph
Advanced tools
Comparing version 1.0.8 to 1.0.9
@@ -97,3 +97,3 @@ | ||
if (typeof(module) !== 'undefined' && typeof(exports) !== 'undefined' && typeof(d3) == 'undefined') { | ||
var d3 = require('d3'); | ||
d3 = require('d3'); | ||
} | ||
@@ -119,3 +119,4 @@ | ||
clickHandler = null, | ||
minFrameSize = 0; | ||
minFrameSize = 0, | ||
details = null; | ||
@@ -147,3 +148,2 @@ var tip = d3.tip() | ||
function setDetails(t) { | ||
var details = document.getElementById("details"); | ||
if (details) | ||
@@ -317,3 +317,2 @@ details.innerHTML = t; | ||
function update() { | ||
selection.each(function(root) { | ||
@@ -413,3 +412,3 @@ var x = d3.scaleLinear().range([0, w]), | ||
var node = data.find(function (element) { | ||
return (name(element) === name(sample)); | ||
return (element.name === sample.name); | ||
}); | ||
@@ -588,2 +587,3 @@ | ||
newRoot = d3.hierarchy(root.data, function(d) { return children(d); }); | ||
injectIds(newRoot); | ||
}); | ||
@@ -606,11 +606,17 @@ selection = selection.datum(newRoot); | ||
chart.details = function (_) { | ||
if (!arguments.length) { return details; } | ||
details = _; | ||
return chart; | ||
}; | ||
return chart; | ||
} | ||
d3.flameGraph = flameGraph; | ||
// Node/CommonJS exports | ||
if (typeof(module) !== 'undefined' && typeof(exports) !== 'undefined') { | ||
module.exports = flameGraph; | ||
} else { | ||
d3.flameGraph = flameGraph; | ||
} | ||
})(); |
@@ -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 r(t){return t.v||t.value}function i(t){var n=document.getElementById("details");n&&(n.innerHTML=t)}function a(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 u(t){var n=0;if(t){var e=t.split("`");e.length>1&&(t=e[e.length-1]),t=t.split("(")[0],n=a(t)}var r=200+Math.round(55*n),i=0+Math.round(230*(1-n)),u=0+Math.round(55*(1-n));return"rgb("+r+","+i+","+u+")"}function o(t){t.data.original||(t.data.original=r(t)),t.data.v=0,t.data.value&&delete t.data.value,n(t)&&n(t).forEach(o)}function f(t){t.data.fade=!1,t.data.original&&(t.data.v=t.data.original),n(t)&&n(t).forEach(f)}function c(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 l(t){var n=c(t);n.forEach(function(t){o(t)}),t.parent&&l(t.parent)}function d(t){t.parent&&(t.parent.data.fade=!0,d(t.parent))}function h(t){B.hide(t),l(t),f(t),d(t),m(),"function"==typeof H&&H(t)}function s(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 g(t){t.highlight=!1,n(t)&&n(t).forEach(function(t){g(t)})}function p(n,r){return"function"==typeof q?q(n,r):q?e.ascending(t(n),t(r)):void 0}function v(t){var n=t.descendants();if(S>0){var e=A/(t.x1-t.x0);n=n.filter(function(t){return(t.x1-t.x0)*e>S})}return n}function m(){T.each(function(a){function u(t){return(t.x1-t.x0)*c}var o=e.scaleLinear().range([0,A]),f=e.scaleLinear().range([0,O]);q&&a.sort(p),a.sum(function(t){if(t.fade||!r(t))return 0;var e=r(t);if(n(t))for(var i=n(t),a=0;a<i.length;a++)e-=i[a].value;return e}),G(a);var c=A/(a.x1-a.x0),l=v(a),d=e.select(this).select("svg").selectAll("g").data(l,function(t){return t.id});d.transition().duration(C).ease(L).attr("transform",function(t){return"translate("+o(t.x0)+","+(z?f(t.depth):M-f(t.depth)-O)+")"}),d.select("rect").attr("width",u);var s=d.enter().append("svg:g").attr("transform",function(t){return"translate("+o(t.x0)+","+(z?f(t.depth):M-f(t.depth)-O)+")"});s.append("svg:rect").transition().delay(C/2).attr("width",u),j||s.append("svg:title"),s.append("foreignObject").append("xhtml:div"),d=e.select(this).select("svg").selectAll("g").data(l,function(t){return t.id}),d.attr("width",u).attr("height",function(t){return O}).attr("name",function(n){return t(n)}).attr("class",function(t){return t.data.fade?"frame fade":"frame"}),d.select("rect").attr("height",function(t){return O}).attr("fill",function(t){return F(t)}),j||d.select("title").text(D),d.select("foreignObject").attr("width",u).attr("height",function(t){return O}).select("div").attr("class","label").style("display",function(t){return u(t)<35?"none":"block"}).transition().delay(C).text(t),d.on("click",h),d.exit().remove(),d.on("mouseover",function(t){j&&B.show(t),i(D(t))}).on("mouseout",function(t){j&&B.hide(t),i("")})})}function y(n,e){e.forEach(function(e){var r=n.find(function(n){return t(n)===t(e)});r?(r.original?r.original+=e.value:r.value+=e.value,e.children&&(r.children||(r.children=[]),y(r.children,e.children))):n.push(e)})}function x(){return Math.floor(65536*(1+Math.random())).toString(16).substring(1)}function w(t){t.id=x()+"-"+x()+"--"+x()+"-"+x();for(var n=t.c||t.children||[],e=0;e<n.length;e++)w(n[e])}function E(t){var r=e.hierarchy(t.datum(),function(t){return n(t)});return w(r),T=t.datum(r),arguments.length?(M||(M=(r.height+2)*O),T.each(function(t){b||(b=e.select(this).append("svg:svg").attr("width",A).attr("height",M).attr("class","partition d3-flame-graph").call(B),b.append("svg:text").attr("class","title").attr("text-anchor","middle").attr("y","25").attr("x",A/2).attr("fill","#808080").text(k))}),void m()):E}var b,A=960,M=null,O=18,T=null,j=!0,k="",C=750,L=e.easeCubic,q=!1,z=!1,H=null,S=0,B=e.tip().direction("s").offset([8,0]).attr("class","d3-flame-graph-tip").html(function(t){return D(t)}),D=function(n){return t(n)+" ("+e.format(".3f")(100*(n.x1-n.x0),3)+"%, "+r(n)+" samples)"},F=function(n){return n.highlight?"#E600E6":u(t(n))},G=e.partition();return E.height=function(t){return arguments.length?(M=t,E):M},E.width=function(t){return arguments.length?(A=t,E):A},E.cellHeight=function(t){return arguments.length?(O=t,E):O},E.tooltip=function(t){return arguments.length?("function"==typeof t&&(B=t),j=!!t,E):j},E.title=function(t){return arguments.length?(k=t,E):k},E.transitionDuration=function(t){return arguments.length?(C=t,E):C},E.transitionEase=function(t){return arguments.length?(L=t,E):L},E.sort=function(t){return arguments.length?(q=t,E):q},E.reversed=function(t){return arguments.length?(z=t,E):z},E.label=function(t){return arguments.length?(D=t,E):D},E.search=function(t){var n=[];return T.each(function(e){n=s(e,t),m()}),n},E.clear=function(){T.each(function(t){g(t),m()})},E.zoomTo=function(t){h(t)},E.resetZoom=function(){T.each(function(t){h(t)})},E.onClick=function(t){return arguments.length?(H=t,E):H},E.merge=function(t){var r;T.each(function(i){y([i.data],[t]),r=e.hierarchy(i.data,function(t){return n(t)})}),T=T.datum(r),m()},E.color=function(t){return arguments.length?(F=t,E):F},E.minFrameSize=function(t){return arguments.length?(S=t,E):S},E}if(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 e)var e=require("d3");"undefined"!=typeof module&&"undefined"!=typeof exports&&"undefined"==typeof e.tip&&(e.tip=require("d3-tip")),e.flameGraph=n,"undefined"!=typeof module&&"undefined"!=typeof exports&&(module.exports=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.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}(); |
{ | ||
"name": "d3-flame-graph", | ||
"version": "1.0.8", | ||
"version": "1.0.9", | ||
"description": "A d3.js library to produce flame graphs.", | ||
@@ -5,0 +5,0 @@ "main": "src/d3.flameGraph.js", |
@@ -208,2 +208,17 @@ # d3-flame-graph | ||
<a name="details" href="#details">#</a> flameGraph.<b>details</b>(<i>[element]</i>) | ||
Sets the element that should be updated with the focused sample details text. Example: | ||
```html | ||
<div id="details"> | ||
</div> | ||
``` | ||
```js | ||
flameGraph.details(document.getElementById("details")); | ||
``` | ||
If called with no arguments, `onClick` will return the click handler. | ||
## Issues | ||
@@ -210,0 +225,0 @@ |
@@ -97,3 +97,3 @@ | ||
if (typeof(module) !== 'undefined' && typeof(exports) !== 'undefined' && typeof(d3) == 'undefined') { | ||
var d3 = require('d3'); | ||
d3 = require('d3'); | ||
} | ||
@@ -119,3 +119,4 @@ | ||
clickHandler = null, | ||
minFrameSize = 0; | ||
minFrameSize = 0, | ||
details = null; | ||
@@ -147,3 +148,2 @@ var tip = d3.tip() | ||
function setDetails(t) { | ||
var details = document.getElementById("details"); | ||
if (details) | ||
@@ -317,3 +317,2 @@ details.innerHTML = t; | ||
function update() { | ||
selection.each(function(root) { | ||
@@ -413,3 +412,3 @@ var x = d3.scaleLinear().range([0, w]), | ||
var node = data.find(function (element) { | ||
return (name(element) === name(sample)); | ||
return (element.name === sample.name); | ||
}); | ||
@@ -588,2 +587,3 @@ | ||
newRoot = d3.hierarchy(root.data, function(d) { return children(d); }); | ||
injectIds(newRoot); | ||
}); | ||
@@ -606,11 +606,17 @@ selection = selection.datum(newRoot); | ||
chart.details = function (_) { | ||
if (!arguments.length) { return details; } | ||
details = _; | ||
return chart; | ||
}; | ||
return chart; | ||
} | ||
d3.flameGraph = flameGraph; | ||
// Node/CommonJS exports | ||
if (typeof(module) !== 'undefined' && typeof(exports) !== 'undefined') { | ||
module.exports = flameGraph; | ||
} else { | ||
d3.flameGraph = flameGraph; | ||
} | ||
})(); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
11401855
11674
258