ngx-flamegraph
TypeScript icon, indicating that this package has built-in type declarations

0.0.12 • Public • Published

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

Readme

Keywords

none

Package Sidebar

Install

npm i ngx-flamegraph

Weekly Downloads

812

Version

0.0.12

License

MIT

Unpacked Size

189 kB

Total Files

30

Last publish

Collaborators

  • mgechev