Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

d3-flame-graph

Package Overview
Dependencies
Maintainers
1
Versions
66
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

d3-flame-graph - npm Package Compare versions

Comparing version 2.0.1 to 2.0.2

examples/diff_rsync_v1.json

2

package.json
{
"name": "d3-flame-graph",
"version": "2.0.1",
"version": "2.0.2",
"description": "A d3.js library to produce flame graphs.",

@@ -5,0 +5,0 @@ "main": "dist/d3-flamegraph.js",

@@ -25,2 +25,3 @@ import { select } from 'd3-selection'

var selfValue = false
var differential = false

@@ -43,2 +44,6 @@ var tip = d3Tip()

function getDelta (d) {
return d.data.d || d.data.delta
}
function children (d) {

@@ -61,3 +66,3 @@ return d.c || d.children

var colorMapper = function (d) {
return d.highlight ? '#E600E6' : colorHash(name(d), libtype(d))
return d.highlight ? '#E600E6' : colorHash(name(d), libtype(d), getDelta(d))
}

@@ -89,3 +94,3 @@

function colorHash (name, libtype) {
function colorHash (name, libtype, delta) {
// Return a color for the given name and library type. The library type

@@ -98,60 +103,77 @@ // selects the hue, and the name is hashed to a color in that hue.

// Select hue. Order is important.
var hue
if (typeof libtype === 'undefined' || libtype === '') {
if (differential) {
r = 220
g = 220
b = 220
if (!delta) {
delta = 0
}
if (delta > 0) {
b = Math.round(210 * (maxDelta - delta) / maxDelta)
g = b
} else if (delta < 0) {
r = Math.round(210 * (maxDelta + delta) / maxDelta)
g = r
}
} else {
// default when libtype is not in use
hue = 'warm'
} else {
hue = 'red'
if (typeof name !== 'undefined' && name && name.match(/::/)) {
hue = 'yellow'
var hue = 'warm'
if (!(typeof libtype === 'undefined' || libtype === '')) {
// Select hue. Order is important.
hue = 'red'
if (typeof name !== 'undefined' && name && name.match(/::/)) {
hue = 'yellow'
}
if (libtype === 'kernel') {
hue = 'orange'
} else if (libtype === 'jit') {
hue = 'green'
} else if (libtype === 'inlined') {
hue = 'aqua'
}
}
if (libtype === 'kernel') {
hue = 'orange'
} else if (libtype === 'jit') {
hue = 'green'
} else if (libtype === 'inlined') {
hue = 'aqua'
// calculate hash
var vector = 0
if (name) {
var nameArr = name.split('`')
if (nameArr.length > 1) {
name = nameArr[nameArr.length - 1] // drop module name if present
}
name = name.split('(')[0] // drop extra info
vector = generateHash(name)
}
}
// calculate hash
var vector = 0
if (name) {
var nameArr = name.split('`')
if (nameArr.length > 1) {
name = nameArr[nameArr.length - 1] // drop module name if present
// calculate color
if (hue === 'red') {
r = 200 + Math.round(55 * vector)
g = 50 + Math.round(80 * vector)
b = g
} else if (hue === 'orange') {
r = 190 + Math.round(65 * vector)
g = 90 + Math.round(65 * vector)
b = 0
} else if (hue === 'yellow') {
r = 175 + Math.round(55 * vector)
g = r
b = 50 + Math.round(20 * vector)
} else if (hue === 'green') {
r = 50 + Math.round(60 * vector)
g = 200 + Math.round(55 * vector)
b = r
} else if (hue === 'aqua') {
r = 50 + Math.round(60 * vector)
g = 165 + Math.round(55 * vector)
b = g
} else {
// original warm palette
r = 200 + Math.round(55 * vector)
g = 0 + Math.round(230 * (1 - vector))
b = 0 + Math.round(55 * (1 - vector))
}
name = name.split('(')[0] // drop extra info
vector = generateHash(name)
}
// calculate color
if (hue === 'red') {
r = 200 + Math.round(55 * vector)
g = 50 + Math.round(80 * vector)
b = g
} else if (hue === 'orange') {
r = 190 + Math.round(65 * vector)
g = 90 + Math.round(65 * vector)
b = 0
} else if (hue === 'yellow') {
r = 175 + Math.round(55 * vector)
g = r
b = 50 + Math.round(20 * vector)
} else if (hue === 'green') {
r = 50 + Math.round(60 * vector)
g = 200 + Math.round(55 * vector)
b = r
} else if (hue === 'aqua') {
r = 50 + Math.round(60 * vector)
g = 165 + Math.round(55 * vector)
b = g
} else {
// original warm palette
r = 200 + Math.round(55 * vector)
g = 0 + Math.round(230 * (1 - vector))
b = 0 + Math.round(55 * (1 - vector))
}
return 'rgb(' + r + ',' + g + ',' + b + ')'

@@ -412,2 +434,13 @@ }

var maxDelta = 0
function calculateMaxDelta (node) {
var delta = Math.abs(getDelta(node))
maxDelta = delta > maxDelta ? delta : maxDelta
var children = node.c || node.children || []
for (var i = 0; i < children.length; i++) {
calculateMaxDelta(children[i])
}
}
function chart (s) {

@@ -418,2 +451,7 @@ var root = hierarchy(

injectIds(root)
if (differential) {
calculateMaxDelta(root)
}
selection = s.datum(root)

@@ -503,2 +541,8 @@

chart.differential = function (_) {
if (!arguments.length) { return differential }
differential = _
return chart
}
chart.label = function (_) {

@@ -505,0 +549,0 @@ if (!arguments.length) { return label }

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc