0.0.12 • Published 1 year ago

ngx-flamegraph v0.0.12

Weekly downloads
71
License
MIT
Repository
-
Last release
1 year ago

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 type RawData[]. RawData is the same interface as Data in the example above.
  • siblingLayout - equal or relative. Equal will set all the siblings with the same width, compared to relative, 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

0.0.12

1 year ago

0.0.11

2 years ago

0.0.10

3 years ago

0.0.9

3 years ago

0.0.8

4 years ago

0.0.7

4 years ago

0.0.5

4 years ago

0.0.4

4 years ago

0.0.6

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago