1 import { Component, Input, OnChanges } from '@angular/core';
3 import * as _ from 'lodash';
6 selector: 'cd-osd-performance-histogram',
7 templateUrl: './osd-performance-histogram.component.html',
8 styleUrls: ['./osd-performance-histogram.component.scss']
10 export class OsdPerformanceHistogramComponent implements OnChanges {
22 hexdigits(v: number): string {
23 const i = Math.floor(v * 255).toString(16);
24 return i.length === 1 ? '0' + i : i;
27 hexcolor(r: number, g: number, b: number) {
28 return '#' + this.hexdigits(r) + this.hexdigits(g) + this.hexdigits(b);
32 if (!this.histogram) {
37 _.each(this.histogram.values, (row, i) => {
38 _.each(row, (col, j) => {
40 if (this.last && this.last[i] && this.last[i][j]) {
41 val = col - this.last[i][j];
45 max = Math.max(max, val);
49 this.valuesStyle = this.histogram.values.map((row: any, i: number) => {
50 return row.map((col: any, j: number) => {
51 const val = this.last && this.last[i] && this.last[i][j] ? col - this.last[i][j] : col;
52 const g = max ? val / max : 0;
54 return { backgroundColor: this.hexcolor(r, g, 0) };
58 this.last = this.histogram.values;