diff --git a/client/src/components/Graph.vue b/client/src/components/Graph.vue index e2999a0..a40a9d4 100644 --- a/client/src/components/Graph.vue +++ b/client/src/components/Graph.vue @@ -86,7 +86,7 @@ async function resolveDataThreshold(range: TimeRange): Promise<{ // TODO: remove code repetition async function resolveDataAnomaly(range: TimeRange): Promise<{ timeserie: LineTimeSerie[], - + bounds: [number, [number, number]][], segments: Segment[] }> { @@ -107,18 +107,9 @@ async function resolveDataAnomaly(range: TimeRange): Promise<{ target: "HSR", datapoints: hsr.map(([t, v, [l, u]]) => [t, v]), color: 'red' - }, - { - target: "HSR_Upper_bound", - datapoints: hsr.map(([t, v, [u, l]]) => [t, u]), - color: 'red' - }, - { - target: "HSR_Lower_bound", - datapoints: hsr.map(([t, v, [u, l]]) => [t, l]), - color: 'red' } ], + bounds: hsr.map(([t, v, [u, l]]) => [t, [u, l]]), segments: segments, } } catch (e) { diff --git a/client/src/components/pods/anomaly_pod.ts b/client/src/components/pods/anomaly_pod.ts index 920cb42..5e8edfd 100644 --- a/client/src/components/pods/anomaly_pod.ts +++ b/client/src/components/pods/anomaly_pod.ts @@ -8,12 +8,17 @@ import { SegmentsSet } from '@/types/segment_set'; export type UpdateDataCallback = (range: TimeRange) => Promise<{ timeserie: LineTimeSerie[], + bounds: [number, [number, number]][], segments: Segment[] }>; +import * as _ from 'lodash'; + export class AnomalyPod extends HasticPod { + _bounds: [number, [number, number]][]; + constructor( el: HTMLElement, udc: UpdateDataCallback, @@ -36,15 +41,45 @@ export class AnomalyPod extends HasticPod { this.udc({ from, to }) .then(resp => { this.updateSegments(resp.segments); + this.updateBounds(resp.bounds); this.updateData(resp.timeserie, undefined, true); + }) .catch(() => { /* set "error" message */ }) } + renderMetrics() { + this.renderBounds() + super.renderMetrics(); + + } + + updateBounds(bounds: [number, [number, number]][]) { + this._bounds = bounds; + } + + renderBounds() { + + // TODO: check the case when this._bounds == undefined + if(this._bounds == undefined) { + return; + } + + const pointsUp = this._bounds.map(([t, [u, _]]) => [t, u]) + const pointsDown = this._bounds.map(([t, [_, l]]) => [t, l]); + + const points = pointsUp.reverse().concat(pointsDown) + .map(([t, v]) => `${this.xScale(t)},${this.yScale(v)}`) + .join(' ') - protected updateSegments(segments: Segment[]): void { - this.segmentSet.clear(); - this.segmentSet.setSegments(segments); + this.metricContainer + .append('g') + .append('polygon') + .attr('fill', 'green') + .attr('stroke', 'none') + .attr('fill-opacity', 0.2) + .attr('pointer-events', 'none') + .attr('points', points); } } \ No newline at end of file diff --git a/client/src/components/pods/hastic_pod.ts b/client/src/components/pods/hastic_pod.ts index 9dbc12b..5572f9a 100644 --- a/client/src/components/pods/hastic_pod.ts +++ b/client/src/components/pods/hastic_pod.ts @@ -41,7 +41,6 @@ export abstract class HasticPod extends LinePod { this.renderSegments(); } - protected addEvents(): void { this.initBrush(); this.initPan(); @@ -103,6 +102,11 @@ export abstract class HasticPod extends LinePod { this.fetchData(); } + protected updateSegments(segments: Segment[]): void { + this.segmentSet.clear(); + this.segmentSet.setSegments(segments); + } + abstract fetchData(); } diff --git a/client/src/components/pods/pattern_pod.ts b/client/src/components/pods/pattern_pod.ts index cee788a..4ae40d0 100644 --- a/client/src/components/pods/pattern_pod.ts +++ b/client/src/components/pods/pattern_pod.ts @@ -178,12 +178,6 @@ export class PatternPod extends HasticPod { } - // TODO: maybe not override this - protected updateSegments(segments: Segment[]): void { - this.segmentSet.clear(); - this.segmentSet.setSegments(segments); - } - // TODO: move to "controller" private _tempIdCounted = -1; public getNewTempSegmentId(): SegmentId { diff --git a/client/src/components/pods/threshold_pod.ts b/client/src/components/pods/threshold_pod.ts index a2341ea..239ba0a 100644 --- a/client/src/components/pods/threshold_pod.ts +++ b/client/src/components/pods/threshold_pod.ts @@ -41,10 +41,4 @@ export class ThresholdPod extends HasticPod { .catch(() => { /* set "error" message */ }) } - // TODO: maybe not override this - protected updateSegments(segments: Segment[]): void { - this.segmentSet.clear(); - this.segmentSet.setSegments(segments); - } - } \ No newline at end of file diff --git a/client/src/views/Home.vue b/client/src/views/Home.vue index f3a3f59..8f2ea92 100644 --- a/client/src/views/Home.vue +++ b/client/src/views/Home.vue @@ -22,7 +22,7 @@ Holde key
D
to delete patterns

- Correlation score: + Correlation score:
Anti correlation score: