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 {
11 @Input() histogram: any;
21 hexdigits(v): string {
22 const i = Math.floor(v * 255).toString(16);
23 return i.length === 1 ? '0' + i : i;
27 return '#' + this.hexdigits(r) + this.hexdigits(g) + this.hexdigits(b);
31 if (!this.histogram) {
36 _.each(this.histogram.values, (row, i) => {
37 _.each(row, (col, j) => {
39 if (this.last && this.last[i] && this.last[i][j]) {
40 val = col - this.last[i][j];
44 max = Math.max(max, val);
48 this.valuesStyle = this.histogram.values.map((row, i) => {
49 return row.map((col, j) => {
50 const val = this.last && this.last[i] && this.last[i][j] ? col - this.last[i][j] : col;
51 const g = max ? val / max : 0;
53 return { backgroundColor: this.hexcolor(r, g, 0) };
57 this.last = this.histogram.values;