From 6be5d9f4df06d8a1109a65cab10759491a5a9740 Mon Sep 17 00:00:00 2001 From: Rania Chowdhury Date: Sat, 30 Mar 2019 15:39:24 -0400 Subject: [PATCH] initial user input graphs, no multiple generators yet --- package.json | 1 + ...s.service.spec.ts => data.service.spec.ts} | 4 +- src/app/services/data.service.ts | 108 +++++++++++ src/app/services/names.service.ts | 182 ----------------- src/app/services/visualize.service.ts | 67 ++++++- .../visualize-all/visualize-all.component.css | 17 +- .../visualize-all.component.html | 42 ++-- .../visualize-all/visualize-all.component.ts | 183 +++++++++++------- 8 files changed, 322 insertions(+), 282 deletions(-) rename src/app/services/{names.service.spec.ts => data.service.spec.ts} (66%) create mode 100644 src/app/services/data.service.ts delete mode 100644 src/app/services/names.service.ts diff --git a/package.json b/package.json index 2becbdb..4f3019a 100644 --- a/package.json +++ b/package.json @@ -25,6 +25,7 @@ "chart.js": "^2.7.3", "core-js": "^2.6.3", "hammerjs": "^2.0.8", + "moment": "^2.24.0", "rxjs": "^6.2.2", "rxjs-compat": "^6.2.2", "zone.js": "^0.8.29" diff --git a/src/app/services/names.service.spec.ts b/src/app/services/data.service.spec.ts similarity index 66% rename from src/app/services/names.service.spec.ts rename to src/app/services/data.service.spec.ts index a83901b..2a0d50b 100644 --- a/src/app/services/names.service.spec.ts +++ b/src/app/services/data.service.spec.ts @@ -1,12 +1,12 @@ import { TestBed } from '@angular/core/testing'; -import { NamesService } from './names.service'; +import { DataService } from './data.service'; describe('NamesService', () => { beforeEach(() => TestBed.configureTestingModule({})); it('should be created', () => { - const service: NamesService = TestBed.get(NamesService); + const service: DataService = TestBed.get(NamesService); expect(service).toBeTruthy(); }); }); diff --git a/src/app/services/data.service.ts b/src/app/services/data.service.ts new file mode 100644 index 0000000..71bfa87 --- /dev/null +++ b/src/app/services/data.service.ts @@ -0,0 +1,108 @@ +import { Injectable } from '@angular/core'; + +@Injectable({ + providedIn: 'root' +}) +export class DataService { + + convChart = [ + ['l1.l2.voltage', '400001', 'L1 - L2 Voltage', 'RO', 'WORD', 'Volts AC'], + ['l2.l3.voltage', '400002', 'L2 - L3 Voltage', 'RO', 'WORD', 'Volts AC'], + ['l3.l1.voltage', '400003', 'L3 - L1 Voltage', 'RO', 'WORD', 'Volts AC'], + ['l1.l0.voltage', '400004', 'L1 - L0 Voltage', 'RO', 'WORD', 'Volts AC'], + ['l2.l0.voltage', '400005', 'L2 - L0 Voltage', 'RO', 'WORD', 'Volts AC'], + ['l3.l0.voltage', '400006', 'L3 - L0 Voltage', 'RO', 'WORD', 'Volts AC'], + ['l1.current', '400007', 'L1 Current', 'RO', 'WORD', 'Amps AC'], + ['l2.current', '400008', 'L2 Current', 'RO', 'WORD', 'Amps AC'], + ['l3.current', '400009', 'L3 Current', 'RO', 'WORD', 'Amps AC'], + ['frequency', '400010', 'Frequency', 'RO', 'WORD', 'Hz X 100'], + ['total.kw', '400011', 'Total kW', 'RO', 'WORD', 'kW'], + ['rate.kw', '400012', 'Percent of Rated kW', 'RO', 'WORD', '% Rated kW'], + ['total.pf', '400013', 'Total Power Factor', 'RO', 'SWORD', 'PF X 100 (SIGNED)'], + ['l1.kw', '400014', 'L1 kW', 'RO', 'WORD', 'kW'], + ['l1.pf', '400015', 'L1 Power Factor', 'RO', 'SWORD', 'PF X 100 (SIGNED)'], + ['l2.kw', '400016', 'L2 kW', 'RO', 'WORD', 'kW'], + ['l2.pf', '400017', 'L2 Power Factor', 'RO', 'SWORD', 'PF X 100 (SIGNED)'], + ['l3.kw', '400018', 'L3 kW', 'RO', 'WORD', 'kW'], + ['l3.pf', '400019', 'L3 Power Factor', 'RO', 'SWORD', 'PF X 100 (SIGNED)'], + ['total.kvar', '400020', 'Total kVAR', 'RO', 'SWORD', 'kVAR (SIGNED)'], + ['l1.kvar', '400021', 'L1 kVAR', 'RO', 'SWORD', 'kVAR (SIGNED)'], + ['l2.kvar', '400022', 'L2 kVAR', 'RO', 'SWORD', 'kVAR (SIGNED)'], + ['l3.kvar', '400023', 'L3 kVAR', 'RO', 'SWORD', 'kVAR (SIGNED)'], + ['total.kva', '400024', 'Total kVA', 'RO', 'WORD', 'kVA'], + ['l1.kva', '400025', 'L1 kVA', 'RO', 'WORD', 'kVA'], + ['l2.kva', '400026', 'L2 kVA', 'RO', 'WORD', 'kVA'], + ['l3.kva', '400027', 'L3 kVA', 'RO', 'WORD', 'kVA'], + [, '400028', 'Current Lead/Lag', 'RO', 'WORD', + 'Bits 0-1 Total Current - Leading = 10 Lagging = 01 Bits 2-3 L1 Current -' + + 'Leading = 10 Lagging = 01 Bits 4-5 L2 Current - Leading = 10 Lagging = 01 Bits 6-7 L3 Current - Leading = 10 Lagging = 01'], + [, '400029', 'Reserved For Future Use', 'RO', 'WORD', 'Returns 0 (zero)'], + [, '400030', 'Reserved For Future Use', 'RO', 'WORD', 'Returns 0 (zero)'], + [, '400031', 'Reserved For Future Use', 'RO', 'WORD', 'Returns 0 (zero)'], + [, '400032', 'Reserved For Future Use', 'RO', 'WORD', 'Returns 0 (zero)'], + ['oil.pressure', '400033', 'Oil Pressure*', 'RO', 'WORD', 'kPa/psi'], + ['coolant.temp', '400034', 'Coolant Temperature*', 'RO', 'SWORD', 'Degrees C/Degrees F'], + ['engine.rpm', '400035', 'Engine Speed*', 'RO', 'WORD', 'RPM'], + ['battery.voltage', '400036', 'Local Battery Voltage*', 'RO', 'WORD', 'Volts DC X 10'], + ['fuel.pressure', '400037', 'Fuel Pressure*', 'RO', 'WORD', 'kPa/psi DDEC/MDEC/ADEC only'], + ['fuel.temp', '400038', 'Fuel Temperature*', 'RO', 'SWORD', 'Degrees C/Degrees F DDEC/MDEC/ADEC only'], + ['fuel.rate', '400039', 'Fuel Rate*', 'RO', 'WORD', 'Liters/Hour X 100 or Gallons/Hour X 100 DDEC only'], + [, '400040', 'Used Last Run*', 'RO', 'WORD', 'Liters/Gallons DDEC only'], + ['coolant.pressure', '400041', 'Coolant Pressure*', 'RO', 'WORD', 'kPa/psi DDEC only'], + ['coolant.level', '400042', 'Coolant Level*', 'RO', 'WORD', '% X 10 DDEC only'], + ['oil.temp', '400043', 'Lube Oil Temperature*', 'RO', 'SWORD', 'Degrees C/Degrees F DDEC/MDEC/ADEC/Waukesha only'], + ['oil.level', '400044', 'Oil Level*', 'RO', 'WORD', '% X 10 DDEC only'], + ['crankcase.pressure', '400045', 'Crankcase Pressure*', 'RO', 'WORD', 'kPa/psi DDEC only'], + ['ambient.temp', '400046', 'Ambient Temperature *', 'RO', 'SWORD', 'Degrees C/Degrees F DDEC only'], + ['ecm.battery.voltage', '400047', 'ECM Battery Voltage*', 'RO', 'WORD', 'Volts DC X 10 DDEC/MDEC/ADEC only'], + [, '400048', 'ECM Status', 'RO', 'WORD', '0 = DDEC-Equipped, 1 = Non-ECM, 2 = MDEC/ADEC-Equipped'], + ['intake.temp', '400049', 'Intake Air Temperature', 'RO', 'SWORD', 'Degrees C/Degrees F MDEC/ADEC/Waukesha only'], + ['intake.pressure', '400050', 'Intake Air Pressure', 'RO', 'WORD', 'Degrees C/Degrees F MDEC/ADEC only'] + ]; + + constructor() { } + + getUnits(metric) { + let conv; + for (conv of this.convChart) { + if (conv[0] === metric) { + return conv[5]; + } + } + } + + convertNames(input, type) { // "type" you are converting to + let conv; + if (type === 'layman') { + for (conv of this.convChart) { + if (conv[0] === input) { + return conv[2]; + } + } + } else if (type === 'metric') { + for (conv of this.convChart) { + if (conv[2] === input) { + return conv[0]; + } + } + } + } + + getAllNames(type) { + if (type === 'layman') { + const layArray = []; + let conv; + for (conv of this.convChart) { + layArray.push(conv[2]); + } + return layArray; + } else if (type === 'metric') { + const metArray = []; + let conv; + for (conv of this.convChart) { + metArray.push(conv[2]); + } + return metArray; + } + } +} diff --git a/src/app/services/names.service.ts b/src/app/services/names.service.ts deleted file mode 100644 index 4c88b34..0000000 --- a/src/app/services/names.service.ts +++ /dev/null @@ -1,182 +0,0 @@ -import { Injectable } from '@angular/core'; - -@Injectable({ - providedIn: 'root' -}) -export class NamesService { - - constructor() { } - - convertNames(input, type) { - const convChart = [ - ['L1 - L2 Voltage', 'l1.l2.voltage'], - ['L2 - L3 Voltage', 'l2.l3.voltage'], - ['L3 - L1 Voltage', 'l3.l1.voltage'], - ['L1 - L0 Voltage', 'l1.l0.voltage'], - ['L2 - L0 Voltage', 'l2.l0.voltage'], - ['L3 - L0 Voltage', 'l3.l0.voltage'], - ['L1 Current', 'l1.current'], - ['L2 Current', 'l2.current'], - ['L3 Current', 'l3.current'], - ['Frequency', 'frequency'], - ['Total kW', 'total.kw'], - ['Percent of Rated kW', 'rate.kw'], - ['Total Power Factor', 'total.pf'], - ['L1 kW', 'l1.kw'], - ['L1 Power Factor', 'l1.pf'], - ['L2 kW', 'l2.kw'], - ['L2 Power Factor', 'l2.pf'], - ['L3 kW', 'l3.kw'], - ['L3 Power Factor', 'l3.pf'], - ['Total kVAR', 'total.kvar'], - ['L1 kVAR', 'l1.kvar'], - ['L2 kVAR', 'l2.kvar'], - ['L3 kVAR', 'l3.kvar'], - ['Total kVA', 'total.kva'], - ['L1 kVA', 'l1.kva'], - ['L2 kVA', 'l2.kva'], - ['L3 kVA', 'l3.kva'], - // 'Current Lead / Lag', - // 'Reserved For Future Use', - // 'Reserved For Future Use', - // 'Reserved For Future Use', - // 'Reserved For Future Use', - ['Oil Pressure *', 'oil.pressure'], - ['Coolant Temperature *', 'coolant.temp'], - ['Engine Speed *', 'engine.rpm'], - ['Local Battery Voltage *', 'battery.voltage'], - ['Fuel Pressure *', 'fuel.pressure'], - ['Fuel Temperature *', 'fuel.temp'], - ['Fuel Rate *', 'fuel.rate'], - // 'Used Last Run *', - ['Coolant Pressure *', 'coolant.pressure'], - ['Coolant Level *', 'coolant.level'], - ['Lube Oil Temperature *', 'oil.temp'], - ['Oil Level *', 'oil.level'], - ['Crankcase Pressure *', 'crankcase.pressure'], - ['Ambient Temperature *', 'ambient.temp'], - ['ECM Battery Voltage *', 'ecm.battery.voltage'], - // 'ECM Status', - ['Intake Air Temperature', 'intake.temp'], - ['Intake Air Pressure', 'intake.pressure'] - ]; - - let conv; - if (type === 'layman') { - for (conv of convChart) { - if (conv[1] === input) { - return conv[0]; - } - } - } else if (type === 'metric') { - for (conv of convChart) { - if (conv[0] === input) { - return conv[1]; - } - } - } - } - - getAllNames(type) { - if (type === 'layman') { - return [ - 'L1 - L2 Voltage', - 'L2 - L3 Voltage', - 'L3 - L1 Voltage', - 'L1 - L0 Voltage', - 'L2 - L0 Voltage', - 'L3 - L0 Voltage', - 'L1 Current', - 'L2 Current', - 'L3 Current', - 'Frequency', - 'Total kW', - 'Percent of Rated kW', - 'Total Power Factor', - 'L1 kW', - 'L1 Power Factor', - 'L2 kW', - 'L2 Power Factor', - 'L3 kW', - 'L3 Power Factor', - 'Total kVAR', - 'L1 kVAR', - 'L2 kVAR', - 'L3 kVAR', - 'Total kVA', - 'L1 kVA', - 'L2 kVA', - 'L3 kVA', - // 'Current Lead / Lag', - // 'Reserved For Future Use', - // 'Reserved For Future Use', - // 'Reserved For Future Use', - // 'Reserved For Future Use', - 'Oil Pressure *', - 'Coolant Temperature *', - 'Engine Speed *', - 'Local Battery Voltage *', - 'Fuel Pressure *', - 'Fuel Temperature *', - 'Fuel Rate *', - // 'Used Last Run *', - 'Coolant Pressure *', - 'Coolant Level *', - 'Lube Oil Temperature *', - 'Oil Level *', - 'Crankcase Pressure *', - 'Ambient Temperature *', - 'ECM Battery Voltage *', - // 'ECM Status', - 'Intake Air Temperature', - 'Intake Air Pressure' - ]; - } else if (type === 'metric') { - return [ - 'l1.l2.voltage', - 'l2.l3.voltage', - 'l3.l1.voltage', - 'l1.l0.voltage', - 'l2.l0.voltage', - 'l3.l0.voltage', - 'l1.current', - 'l2.current', - 'l3.current', - 'frequency', - 'total.kw', - 'rate.kw', - 'total.pf', - 'l1.kw', - 'l1.pf', - 'l2.kw', - 'l2.pf', - 'l3.kw', - 'l3.pf', - 'total.kvar', - 'l1.kvar', - 'l2.kvar', - 'l3.kvar', - 'total.kva', - 'l1.kva', - 'l2.kva', - 'l3.kva', - 'oil.pressure', - 'coolant.temp', - 'engine.rpm', - 'battery.voltage', - 'fuel.pressure', - 'fuel.temp', - 'fuel.rate', - 'coolant.pressure', - 'coolant.level', - 'oil.temp', - 'oil.level', - 'crankcase.pressure', - 'ambient.temp', - 'ecm.battery.voltage', - 'intake.temp', - 'intake.pressure' - ]; - } - } -} diff --git a/src/app/services/visualize.service.ts b/src/app/services/visualize.service.ts index 984bb3f..d8e2c8b 100644 --- a/src/app/services/visualize.service.ts +++ b/src/app/services/visualize.service.ts @@ -1,5 +1,7 @@ import { Injectable } from '@angular/core'; import { HttpClient } from '@angular/common/http'; +import { Observable } from 'rxjs'; +import { Chart } from 'chart.js'; @Injectable({ providedIn: 'root' @@ -8,12 +10,71 @@ export class VisualizeService { constructor(private http: HttpClient) { } - getData(token, query) { - return this.http.get('http://sd5-backend.engr.uconn.edu/data/query' + query, { + createChart(labels, data, laymanDataVal) { + return new Chart('canvas', { + type: 'line', + data: { + labels: labels, + datasets: [{ + label: laymanDataVal, + fill: false, + data: data, + backgroundColor: [ + 'rgba(153, 102, 255, 0.2)', + 'rgba(255, 159, 64, 0.2)' + ], + borderColor: 'blue', + borderWidth: 1 + }] + }, + options: { + scales: { + yAxes: [{ + ticks: { + beginAtZero: true + } + }] + } + } + }); + } + + getDataForVis(token, time, func, gens, data): Observable { + const body = { + 'time': { + 'start': time, + 'aggregator': func + }, + 'filters': [ + { + 'tags': [{ + 'type': 'literal_or', + 'tagk': 'generator', + 'filter': gens, + 'groupBy': true + }], + 'id': 'gen' + } + ], + 'metrics': [ + { + 'id': 'a', + 'metric': data, + 'filter': 'gen', + 'fillPolicy': { 'policy': 'nan' } + } + ], + 'expressions': [ + { + 'id': 'e', + 'expr': 'a' + } + ] + }; + return this.http.post('http://sd5-backend.engr.uconn.edu/data/query/exp', body, { headers: { Authorization: 'Bearer ' + token } }); } - } diff --git a/src/app/visualize-all/visualize-all.component.css b/src/app/visualize-all/visualize-all.component.css index 95f7fb8..b79f014 100644 --- a/src/app/visualize-all/visualize-all.component.css +++ b/src/app/visualize-all/visualize-all.component.css @@ -1,21 +1,22 @@ -div#textinput { - width: 300px; -} - select#gen_select { - width: 300px; + width: 180px; } select#func_select { - width: 300px; + width: 180px; } select#data_select { - width: 300px; + width: 180px; } select#time_type_select { - width: 300px; + width: 180px; +} +select#time_span_select { + width: 200px; + padding: 100px; + } p#visMessage { diff --git a/src/app/visualize-all/visualize-all.component.html b/src/app/visualize-all/visualize-all.component.html index b412555..c62c05f 100644 --- a/src/app/visualize-all/visualize-all.component.html +++ b/src/app/visualize-all/visualize-all.component.html @@ -3,46 +3,52 @@

Visualization

{{chart}} +

{{unit$}}

-
+
+ +
diff --git a/src/app/visualize-all/visualize-all.component.ts b/src/app/visualize-all/visualize-all.component.ts index b16276b..d8d0652 100644 --- a/src/app/visualize-all/visualize-all.component.ts +++ b/src/app/visualize-all/visualize-all.component.ts @@ -1,5 +1,6 @@ -import { Component, OnInit, ViewChild } from '@angular/core'; +import { Component, OnInit, ViewChild, ElementRef } from '@angular/core'; import { GeneratorService } from '../services/generator.service'; +import { DataService } from '../services/data.service'; import { VisualizeService } from '../services/visualize.service'; import { Router } from '@angular/router'; import { Chart } from 'chart.js'; @@ -7,6 +8,7 @@ import { Injectable } from '@angular/core'; import { HttpClient, HttpHeaders } from '@angular/common/http'; import 'rxjs/add/operator/map'; import { $ } from 'protractor'; +import * as moment from 'moment'; @Component({ selector: 'app-visualize-all', @@ -16,41 +18,117 @@ import { $ } from 'protractor'; export class VisualizeAllComponent implements OnInit { public generators$: Object; public chart$: Object; + public unit$: any = null; + public dataNames$; public chart: any = null; - // @ViewChild('lineChart') private chartRef; - // chart: any; + public signal = false; + @ViewChild('time_span') timeSpan: ElementRef; - constructor(public graphData: VisualizeService, public genData: GeneratorService, private router: Router, private http: HttpClient) { } + constructor(public data: DataService, public graphData: VisualizeService, public genData: GeneratorService, + private router: Router, private http: HttpClient) { } // create real chart based off of user data resetAndRemakeChart() { - const genVals = Array.prototype.slice.call(document.querySelectorAll('#gen_select option:checked'), 0).map(function(v, i, a) { + const genVals = Array.prototype.slice.call(document.querySelectorAll('#gen_select option:checked'), 0).map(function (v, i, a) { return v.value; }); - const funcVals = Array.prototype.slice.call(document.querySelectorAll('#func_select option:checked'), 0).map(function(v, i, a) { - return v.value; - }); - const dataVals = Array.prototype.slice.call(document.querySelectorAll('#data_select option:checked'), 0).map(function(v, i, a) { + let genVal = ''; + const genCount = genVals.length; + this.signal = false; + if (genVals[0] !== '') { + for (let i = 0; i < genVals.length; i++) { + if (genVal === '') { + genVal = genVals[i]; + } else { + genVal = genVal + '|' + genVals[i]; + } + } + } else if (genCount > 4 ) { + genVal = 'invalid'; + } else { + genVal = 'invalid'; + this.signal = true; + } + + const funcVals = Array.prototype.slice.call(document.querySelectorAll('#func_select option:checked'), 0).map(function (v, i, a) { return v.value; }); - const timeTypeVals = Array.prototype.slice.call(document.querySelectorAll('#data_type_select option:checked'), 0) - .map(function(v, i, a) { + let funcVal = ''; + if (funcVal[0] !== '') { + funcVal = funcVals[0] + ''; + } else { + funcVal = 'invalid'; + this.signal = true; + } + + let laymanDataVal; + const dataVals = Array.prototype.slice.call(document.querySelectorAll('#data_select option:checked'), 0).map(function (v, i, a) { return v.value; }); + let dataVal = ''; + if (dataVals[0] !== '') { + laymanDataVal = dataVal = dataVals[0] + ''; + dataVal = this.data.convertNames(dataVal, 'metric'); + } else { + dataVal = 'invalid'; + this.signal = true; + } + - const visDataJson = { - // 'time span': this.time_span.nativeElement.value - // 'generators': $('#gen_select').val(), - 'generators': genVals, - 'function': funcVals[0], - 'data type': dataVals[0], - 'time type': timeTypeVals[0] - }; - console.log(visDataJson); + const timeTypeVals = Array.prototype.slice.call(document.querySelectorAll('#time_type_select option:checked'), 0) + .map(function (v, i, a) { + return v.value; + }); + let timeTypeVal = ''; + if (timeTypeVals[0] === 'year') { + timeTypeVal = 'y-ago'; + } else if (timeTypeVals[0] === 'day') { + timeTypeVal = 'd-ago'; + } else if (timeTypeVals[0] === 'hour') { + timeTypeVal = 'h-ago'; + } else if (timeTypeVals[0] === 'minute') { + timeTypeVal = 'm-ago'; + } else { + timeTypeVal = 'invalid'; + this.signal = true; + } + + if (this.signal === false) { + + const jsonToken = localStorage.getItem('auth_token'); + + const labels = []; + const data = []; + + try { + // create chart based on user input + this.graphData.getDataForVis(jsonToken, this.timeSpan.nativeElement.value + + timeTypeVal, funcVal, genVal, dataVal).subscribe((graphData) => { + this.chart$ = graphData; + const meta = Object.values(this.chart$['outputs'][0]['dpsMeta']); + for (let n = 0; n < (Object.keys(this.chart$['outputs'][0]['dps']).length); n++) { + const time = moment(this.chart$['outputs'][0]['dps'][n][0]).format('MM-DD-YY hh:mm:ss'); + labels.push(time); + data.push(this.chart$['outputs'][0]['dps'][n][1]); + console.log(this.chart$['outputs'][0]['dps'][n][1]); + } + + this.chart.destroy(); + this.chart = this.graphData.createChart(labels, data, laymanDataVal); + this.unit$ = this.data.getUnits(dataVal); + }); + } catch (err) { + return err; + } + } else if (this.signal === true) { + console.log('invalid entry'); + } } ngOnInit() { + this.dataNames$ = this.data.getAllNames('layman'); + const jsonToken = localStorage.getItem('auth_token'); try { this.genData.getGenerators(jsonToken).subscribe((genData) => { @@ -61,64 +139,31 @@ export class VisualizeAllComponent implements OnInit { return err; } - let labels = []; - let data = []; + const labels = []; + const data = []; + try { // create example chart - this.graphData.getData(jsonToken, '?start=1y-ago&m=sum:oil.temp').subscribe((graphData) => { - this.chart$ = graphData; - const count = Object.keys(this.chart$).length; - let i; - for (i = 0; i < count; i++) { - for (let n = 0; n < (Object.keys(this.chart$[i].dps).length); n++) { - labels = Object.keys(this.chart$[i].dps); - data = Object.values(this.chart$[i].dps); - - } - } - this.chart = new Chart('canvas', { - type: 'line', - data: { - labels: labels, - datasets: [{ - label: i, - fill: false, - data: data, - backgroundColor: [ - 'rgba(255, 99, 132, 0.2)', - 'rgba(54, 162, 235, 0.2)', - 'rgba(255, 206, 86, 0.2)', - 'rgba(75, 192, 192, 0.2)', - 'rgba(153, 102, 255, 0.2)', - 'rgba(255, 159, 64, 0.2)' - ], - borderColor: 'red', - borderWidth: 1 - }] - }, - options: { - scales: { - yAxes: [{ - ticks: { - beginAtZero: true - } - }] - } + this.graphData.getDataForVis(jsonToken, this.timeSpan.nativeElement.value + + '1y-ago', 'sum', '1', 'oil.temp').subscribe((graphData) => { + this.chart$ = graphData; + const meta = Object.values(this.chart$['outputs'][0]['dpsMeta']); + for (let n = 0; n < (Object.keys(this.chart$['outputs'][0]['dps']).length); n++) { + const time = moment(this.chart$['outputs'][0]['dps'][n][0]).format('MM-DD-YY hh:mm:ss'); + labels.push(time); + data.push(this.chart$['outputs'][0]['dps'][n][1]); } - }); - }); + + this.chart = this.graphData.createChart(labels, data, 'Lube Oil Temperature'); + this.unit$ = this.data.getUnits('oil.temp'); + }); + } catch (err) { return err; } - - - - - - } }