import { Component, OnChanges, Input, Output, SimpleChanges, EventEmitter, ChangeDetectionStrategy } from '@angular/core'; @Component({ selector: 'g[ngx-charts-tree-map-cell-series]', template: ` `, changeDetection: ChangeDetectionStrategy.OnPush }) export class TreeMapCellSeriesComponent implements OnChanges { @Input() data; @Input() dims; @Input() colors; @Output() select = new EventEmitter(); cells: any[]; ngOnChanges(changes: SimpleChanges): void { this.cells = this.getCells(); } getCells(): any[] { return this.data.children .filter((d) => { return d.depth === 1; }) .map((d, index) => { let label = d.id; return { x: d.x0, y: d.y0, width: d.x1 - d.x0, height: d.y1 - d.y0, fill: this.colors.getColor(label), label: label, value: d.value, valueType: d.valueType }; }); } getTooltipText({ label, value }): string { return ` ${label} ${value.toLocaleString()} `; } onClick(data): void { this.select.emit(data); } trackBy(index, item): string { return item.label; } }