Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display events in time series chart #354

Open
wants to merge 12 commits into
base: develop
Choose a base branch
from
6 changes: 3 additions & 3 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"d3": "^5.11.0",
"ng-pick-datetime": "^7.0.0",
"ngx-smart-modal": "^7.1.1",
"rxjs": "^6.4.0",
"rxjs": "^6.5.0",
"spin.js": "^4.0.0",
"zone.js": "^0.9.0"
},
Expand Down
1 change: 1 addition & 0 deletions frontend/src/app/enums/url.enum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ export enum URL {
RESULT_COUNT = '/resultSelection/getResultCount',
AGGREGATION_BARCHART_DATA = '/aggregation/getBarchartData',
EVENT_RESULT_DASHBOARD_LINECHART_DATA = '/eventResultDashboard/getLinechartData',
EVENTS = '/rest/events',
DISTRIBUTION_VIOLINCHART_DATA = '/distributionChart/getViolinchartData'
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,18 @@ osm-time-series-line-chart {
}
}

#event-marker-tooltip {
position: absolute;
text-align: left;
font: 10pt sans-serif;
color: white;
background: rgba(0, 0, 0, 0.7);
border: 1px solid rgba(0, 0, 0, 0.4);
border-radius: 3px;
pointer-events: none;
max-width: 250px;
}

#time-series-chart-drawing-area {
.axis {
.domain {
Expand Down Expand Up @@ -64,13 +76,53 @@ osm-time-series-line-chart {
.marker-line {
stroke: $color-contour-medium;
stroke-width: 1px;
opacity: 0.7;
shape-rendering: crispEdges;
}

circle.dot {
stroke-width: 2px;
fill: white;
}

circle.event-marker-dot {
fill: $color-contour-light;
opacity: 0.9;
}

circle.selected-event-marker-dot {
fill: $color-contour-medium;
}

.event-marker-line {
stroke: $color-contour-medium;
stroke-width: 1px;
shape-rendering: crispEdges;
}

.unselected-event-marker-line {
opacity: 0;
}

.selected-event-marker-line {
opacity: 1;
}

circle.event-marker-dot:hover {
fill: $color-contour-medium;
opacity: 0.7;
}

.event-time-line {
stroke: $color-contour-light;
stroke-width: 1px;
shape-rendering: crispEdges;
}

.event-time-line-label {
font-size: 10px;
fill: $color-text-light;
opacity: 0.7;
}
}
}

Expand Down Expand Up @@ -160,3 +212,25 @@ osm-time-series-line-chart {
border-right: 0;
}
}

.grid-container {
display: grid;
}

.event-marker-tooltip-element {
padding: 0.2em 0.75em 0.2em 0.75em;
}

.event-marker-tooltip-date {
margin-bottom: 10px;
}

.event-marker-tooltip-title {
font-weight: bold;
margin: 0;
}

.event-marker-tooltip-text {
margin: 0;
text-align: justify;
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import {LineChartService} from '../../services/line-chart.service';
import {NgxSmartModalService} from 'ngx-smart-modal';
import {SpinnerService} from '../../../shared/services/spinner.service';
import {TranslateService} from '@ngx-translate/core';
import {TimeEvent} from '../../models/event.model';
import {TimeSeries} from '../../models/time-series.model';


@Component({
Expand Down Expand Up @@ -88,9 +90,11 @@ export class TimeSeriesChartComponent implements AfterContentInit, OnChanges {
return;
}

const timeSeries = this.lineChartService.prepareData(this.timeSeriesResults, this.selectedTrimValues);
this.lineChartService.prepareLegend(this.timeSeriesResults);
this.lineChartService.drawLineChart(timeSeries, this.timeSeriesResults.measurandGroups,
const timeSeries: { [key: string]: TimeSeries[] } = this.lineChartService.prepareData(this.timeSeriesResults, this.selectedTrimValues);
const eventData: TimeEvent[] = this.lineChartService.prepareEventsData(this.timeSeriesResults.events);

this.lineChartService.prepareLegendData(this.timeSeriesResults);
this.lineChartService.drawLineChart(timeSeries, eventData, this.timeSeriesResults.measurandGroups,
this.timeSeriesResults.summaryLabels, this.timeSeriesResults.numberOfTimeSeries, this.selectedTrimValues);

this.spinnerService.hideSpinner('time-series-line-chart-spinner');
Expand All @@ -102,10 +106,12 @@ export class TimeSeriesChartComponent implements AfterContentInit, OnChanges {
return;
}

const timeSeries = this.lineChartService.prepareData(this.timeSeriesResults, this.selectedTrimValues);
this.lineChartService.drawLineChart(timeSeries, this.timeSeriesResults.measurandGroups,
const timeSeries: { [key: string]: TimeSeries[] } = this.lineChartService.prepareData(this.timeSeriesResults, this.selectedTrimValues);
const eventData: TimeEvent[] = this.lineChartService.prepareEventsData(this.timeSeriesResults.events);

this.lineChartService.drawLineChart(timeSeries, eventData, this.timeSeriesResults.measurandGroups,
this.timeSeriesResults.summaryLabels, this.timeSeriesResults.numberOfTimeSeries, this.selectedTrimValues);
this.lineChartService.restoreZoom(timeSeries, this.selectedTrimValues);
this.lineChartService.restoreZoom(timeSeries, this.selectedTrimValues, eventData);

this.spinnerService.hideSpinner('time-series-line-chart-spinner');
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,26 @@
import {EventResultSeriesDTO} from './event-result-series.model';
import {EventDTO} from './event.model';
import {SummaryLabel} from './summary-label.model';

export interface EventResultDataDTO {
measurandGroups: { [key: string]: string };
series: EventResultSeriesDTO[];
events: EventDTO[];
summaryLabels: SummaryLabel[];
numberOfTimeSeries: number;
}

export class EventResultData implements EventResultDataDTO {
measurandGroups: { [key: string]: string };
series: EventResultSeriesDTO[];
events: EventDTO[];
summaryLabels: SummaryLabel[];
numberOfTimeSeries: number;

constructor() {
this.measurandGroups = {};
this.series = [];
this.events = [];
this.summaryLabels = [];
this.numberOfTimeSeries = 0;
}
Expand Down
20 changes: 20 additions & 0 deletions frontend/src/app/modules/time-series/models/event.model.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
export interface EventDTO {
id: number;
eventDate: Date;
description: string;
shortName: string;
}

export class TimeEvent implements EventDTO {
id: number;
eventDate: Date;
description: string;
shortName: string;

constructor(id: number, eventDate: Date, description: string, shortName: string) {
this.id = id;
this.eventDate = eventDate;
this.description = description;
this.shortName = shortName;
}
}
Loading