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) {
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];
46 max = Math.max(max, val);
50 this.valuesStyle = this.histogram.values.map((row, i) => {
51 return row.map((col, j) => {
52 const val = this.last && this.last[i] && this.last[i][j] ? col - this.last[i][j] : col;
53 const g = max ? val / max : 0;
55 return {backgroundColor: this.hexcolor(r, g, 0)};
59 this.last = this.histogram.values;