d3-flame-graph
Advanced tools
Comparing version 2.1.3 to 2.1.4
{ | ||
"name": "d3-flame-graph", | ||
"version": "2.1.3", | ||
"version": "2.1.4", | ||
"description": "A d3.js library to produce flame graphs.", | ||
@@ -5,0 +5,0 @@ "main": "dist/d3-flamegraph.js", |
@@ -30,2 +30,4 @@ import { select } from 'd3-selection' | ||
var maxDelta = 0 | ||
var resetHeightOnZoom = false | ||
var scrollOnZoom = false | ||
@@ -260,3 +262,13 @@ var getName = function (d) { | ||
fadeAncestors(d) | ||
update({ resetHeight: true }) | ||
update() | ||
if (scrollOnZoom) { | ||
let chartOffset = svg._groups[0][0].parentNode.offsetTop | ||
let maxFrames = (window.innerHeight - chartOffset) / c | ||
let frameOffset = (d.height - maxFrames + 10) * c | ||
window.scrollTo({ | ||
top: chartOffset + frameOffset, | ||
left: 0, | ||
behavior: 'smooth' | ||
}) | ||
} | ||
if (typeof clickHandler === 'function') { | ||
@@ -343,4 +355,3 @@ clickHandler(d) | ||
function update (options) { | ||
options = options || {} | ||
function update () { | ||
selection.each(function (root) { | ||
@@ -365,3 +376,3 @@ var x = scaleLinear().range([0, w]) | ||
// if height is not set: set height on first update, after nodes were filtered by minFrameSize | ||
if (!h || options.resetHeight) { | ||
if (!h || resetHeightOnZoom) { | ||
var maxDepth = Math.max.apply(null, descendants.map(function (n) { return n.depth })) | ||
@@ -375,3 +386,3 @@ h = (maxDepth + 2) * c | ||
.ease(transitionEase) | ||
.attr('transform', function (d) { return 'translate(' + x(d.x0) + ',' + (inverted ? y(d.depth) : (h - y(d.depth) - c)) + ')' }) | ||
.attr('transform', function (d) { return 'translate(' + x(d.x0) + ',' + (inverted ? y(d.depth) : (h - y(d.depth))) + ')' }) | ||
@@ -386,3 +397,3 @@ g.select('rect') | ||
.append('svg:g') | ||
.attr('transform', function (d) { return 'translate(' + x(d.x0) + ',' + (inverted ? y(d.depth) : (h - y(d.depth) - c)) + ')' }) | ||
.attr('transform', function (d) { return 'translate(' + x(d.x0) + ',' + (inverted ? y(d.depth) : (h - y(d.depth))) + ')' }) | ||
@@ -804,2 +815,14 @@ node.append('svg:rect') | ||
chart.resetHeightOnZoom = function (_) { | ||
if (!arguments.length) { return resetHeightOnZoom } | ||
resetHeightOnZoom = _ | ||
return chart | ||
} | ||
chart.scrollOnZoom = function (_) { | ||
if (!arguments.length) { return scrollOnZoom } | ||
scrollOnZoom = _ | ||
return chart | ||
} | ||
chart.getName = function (_) { | ||
@@ -806,0 +829,0 @@ if (!arguments.length) { return getName } |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
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
12602223
27
9563