d3-flame-graph
Advanced tools
Comparing version 2.1.0 to 2.1.1
{ | ||
"name": "d3-flame-graph", | ||
"version": "2.1.0", | ||
"version": "2.1.1", | ||
"description": "A d3.js library to produce flame graphs.", | ||
@@ -5,0 +5,0 @@ "main": "dist/d3-flamegraph.js", |
@@ -290,2 +290,17 @@ # d3-flame-graph | ||
<a name="setSearchMatch" href="#setSearchMatch">#</a> flamegraph.<b>setSearchMatch</b>(<i>[function]</i>) | ||
Replaces the built-in node search match function. Function takes two arguments, | ||
the node data structure and the search term. It must return a boolean. Example: | ||
```js | ||
flamegraph.setSearchMatch(function(d, term) { | ||
// Non-regex implementation of the search function | ||
return d.data.name.indexOf(term) != 0; | ||
}) | ||
``` | ||
If called with no arguments, `setSearchMatch` will return reset the search | ||
match function. | ||
**All API functions will return the flame graph object if no other behavior is specified in the function details.** | ||
@@ -292,0 +307,0 @@ |
@@ -64,2 +64,9 @@ import { select } from 'd3-selection' | ||
let searchMatch = (d, term) => { | ||
const re = new RegExp(term) | ||
const label = getName(d) | ||
return typeof label !== 'undefined' && label && label.match(re) | ||
} | ||
const originalSearchMatch = searchMatch | ||
var detailsHandler = function (d) { | ||
@@ -260,3 +267,2 @@ if (detailsElement) { | ||
function searchTree (d, term) { | ||
var re = new RegExp(term) | ||
var results = [] | ||
@@ -266,6 +272,5 @@ var sum = 0 | ||
function searchInner (d, foundParent) { | ||
var label = getName(d) | ||
var found = false | ||
if (typeof label !== 'undefined' && label && label.match(re)) { | ||
if (searchMatch(d, term)) { | ||
d.highlight = true | ||
@@ -819,3 +824,12 @@ found = true | ||
chart.setSearchMatch = function (_) { | ||
if (!arguments.length) { | ||
searchMatch = originalSearchMatch | ||
return chart | ||
} | ||
searchMatch = _ | ||
return chart | ||
} | ||
return chart | ||
} |
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
12296931
9416
341