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 {
20 hexdigits(v: number): string {
21 const i = Math.floor(v * 255).toString(16);
22 return i.length === 1 ? '0' + i : i;
25 hexcolor(r: number, g: number, b: number) {
26 return '#' + this.hexdigits(r) + this.hexdigits(g) + this.hexdigits(b);
30 if (!this.histogram) {
35 _.each(this.histogram.values, (row, i) => {
36 _.each(row, (col, j) => {
38 if (this.last && this.last[i] && this.last[i][j]) {
39 val = col - this.last[i][j];
43 max = Math.max(max, val);
47 this.valuesStyle = this.histogram.values.map((row: any, i: number) => {
48 return row.map((col: any, j: number) => {
49 const val = this.last && this.last[i] && this.last[i][j] ? col - this.last[i][j] : col;
50 const g = max ? val / max : 0;
52 return { backgroundColor: this.hexcolor(r, g, 0) };
56 this.last = this.histogram.values;