ngx-flamegraph
Flame graph for Angular. With this package you can visualize stack traces.
Demo
You can try it out here.
Usage
npm i ngx-flamegraph --save
In your app import the NgxFlamegraphModule
:
import { NgxFlamegraphModule } from 'ngx-flamegraph';
@NgModule({
imports: [NgxFlamegraphModule],
// ...
})
export class AppModule {}
Use the ngx-flamegraph
component:
import {Component, OnInit} from '@angular/core';
interface Data {
value: number;
label: string;
children: Data[];
color?: string;
}
@Component({
selector: 'app-root',
template: `
<ngx-flamegraph
[config]="{ data, color }"
[frameClick]="handleClick($event)"
[frameMouseEnter]="handleMouseEnter($event)"
[frameMouseLeave]="handleMouseLeave($event)"
siblingLayout="relative"
[width]="width"
[levelHeight]="30">
</ngx-flamegraph>
`
})
export class AppComponent implements OnInit {
width = window.innerWidth - 100;
// Optional property.
color = {
hue: [50, 0],
saturation: [80, 80],
lightness: [55, 60]
};
data = [
{
label: 'root',
value: 10,
children: [
{ label: 'foo', value: 8, children: [] },
{ label: 'bar', value: 8, color: '#ff0000', children: [] },
]
}
];
handleClick(entry: Data) {
// ...
}
handleMouseEnter(entry: Data) {
// ...
}
handleMouseLeave(entry: Data) {
// ...
}
}
Configuration
-
data
- property of typeRawData[]
.RawData
is the same interface asData
in the example above. -
siblingLayout
-equal
orrelative
. Equal will set all the siblings with the same width, compared torelative
, which will look at their values relative to the sum of the values of all the siblings. -
width
- sets the width of the chart. -
levelHeight
- sets the height per level of the chart.
Related work
ngx-flamegraph
was inspired by the following prior work:
License
MIT