d3-flame-graph
Advanced tools
Comparing version 2.1.8 to 2.1.9
@@ -70,3 +70,37 @@ (function (global, factory) { | ||
function nodeJsColorMapper (d, originalColor) { | ||
let color = originalColor; | ||
const { v8_jit: v8JIT, javascript, optimized } = d.data.extras || {}; | ||
// Non-JS JIT frames (V8 builtins) are greyed out. | ||
if (v8JIT && !javascript) { | ||
color = '#dadada'; | ||
} | ||
// JavaScript frames are colored based on optimization level | ||
if (javascript) { | ||
let opt = (optimized || 0) / d.value; | ||
let r = 255; | ||
let g = 0; | ||
let b = 0; | ||
if (opt < 0.4) { | ||
opt = opt * 2.5; | ||
r = 240 - opt * 200; | ||
} else if (opt < 0.9) { | ||
opt = (opt - 0.4) * 2; | ||
r = 0; | ||
b = 200 - (200 * opt); | ||
g = 100 * opt; | ||
} else { | ||
opt = (opt - 0.9) * 10; | ||
r = 0; | ||
b = 0; | ||
g = 100 + (150 * opt); | ||
} | ||
color = `rgb(${r} , ${g}, ${b})`; | ||
} | ||
return color | ||
} | ||
exports.allocationColorMapper = allocationColorMapper; | ||
exports.nodeJsColorMapper = nodeJsColorMapper; | ||
exports.offCpuColorMapper = offCpuColorMapper; | ||
@@ -73,0 +107,0 @@ |
@@ -1,1 +0,1 @@ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(((t=t||self).d3=t.d3||{},t.d3.flamegraph=t.d3.flamegraph||{},t.d3.flamegraph.colorMapper={}))}(this,(function(t){"use strict";t.allocationColorMapper=function(t){return t.highlight?"rgb(230, 0, 230)":`rgb(${function(t,e,n){const r=n,o=1-r;return[Math.round(t[0]*r+e[0]*o),Math.round(t[1]*r+e[1]*o),Math.round(t[2]*r+e[2]*o)]}([0,255,40],[196,245,233],t.data.value/t.value).join()})`},t.offCpuColorMapper=function(t){if(t.highlight)return"#E600E6";let e=t.data.n||t.data.name,n=0;const r=e.split("`");return r.length>1&&(e=r[r.length-1]),n=function(t){var e=0,n=0,r=1;if(t){for(var o=0;o<t.length&&!(o>6);o++)e+=r*(t.charCodeAt(o)%10),n+=9*r,r*=.7;n>0&&(e/=n)}return e}(e=e.split("(")[0]),"rgb("+(0+Math.round(55*(1-n)))+","+(0+Math.round(230*(1-n)))+","+(200+Math.round(55*n))+")"},Object.defineProperty(t,"__esModule",{value:!0})})); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(((t=t||self).d3=t.d3||{},t.d3.flamegraph=t.d3.flamegraph||{},t.d3.flamegraph.colorMapper={}))}(this,(function(t){"use strict";t.allocationColorMapper=function(t){return t.highlight?"rgb(230, 0, 230)":`rgb(${function(t,e,n){const r=n,o=1-r;return[Math.round(t[0]*r+e[0]*o),Math.round(t[1]*r+e[1]*o),Math.round(t[2]*r+e[2]*o)]}([0,255,40],[196,245,233],t.data.value/t.value).join()})`},t.nodeJsColorMapper=function(t,e){let n=e;const{v8_jit:r,javascript:o,optimized:a}=t.data.extras||{};if(r&&!o&&(n="#dadada"),o){let e=(a||0)/t.value,r=255,o=0,d=0;e<.4?r=240-200*(e*=2.5):e<.9?(r=0,d=200-200*(e=2*(e-.4)),o=100*e):(r=0,d=0,o=100+150*(e=10*(e-.9))),n=`rgb(${r} , ${o}, ${d})`}return n},t.offCpuColorMapper=function(t){if(t.highlight)return"#E600E6";let e=t.data.n||t.data.name,n=0;const r=e.split("`");return r.length>1&&(e=r[r.length-1]),n=function(t){var e=0,n=0,r=1;if(t){for(var o=0;o<t.length&&!(o>6);o++)e+=r*(t.charCodeAt(o)%10),n+=9*r,r*=.7;n>0&&(e/=n)}return e}(e=e.split("(")[0]),"rgb("+(0+Math.round(55*(1-n)))+","+(0+Math.round(230*(1-n)))+","+(200+Math.round(55*n))+")"},Object.defineProperty(t,"__esModule",{value:!0})})); |
{ | ||
"name": "d3-flame-graph", | ||
"version": "2.1.8", | ||
"version": "2.1.9", | ||
"description": "A d3.js library to produce flame graphs.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -63,1 +63,34 @@ function pickHex (color1, color2, weight) { | ||
} | ||
export function nodeJsColorMapper (d, originalColor) { | ||
let color = originalColor | ||
const { v8_jit: v8JIT, javascript, optimized } = d.data.extras || {} | ||
// Non-JS JIT frames (V8 builtins) are greyed out. | ||
if (v8JIT && !javascript) { | ||
color = '#dadada' | ||
} | ||
// JavaScript frames are colored based on optimization level | ||
if (javascript) { | ||
let opt = (optimized || 0) / d.value | ||
let r = 255 | ||
let g = 0 | ||
let b = 0 | ||
if (opt < 0.4) { | ||
opt = opt * 2.5 | ||
r = 240 - opt * 200 | ||
} else if (opt < 0.9) { | ||
opt = (opt - 0.4) * 2 | ||
r = 0 | ||
b = 200 - (200 * opt) | ||
g = 100 * opt | ||
} else { | ||
opt = (opt - 0.9) * 10 | ||
r = 0 | ||
b = 0 | ||
g = 100 + (150 * opt) | ||
} | ||
color = `rgb(${r} , ${g}, ${b})` | ||
} | ||
return color | ||
} |
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
355881
5314