diff --git a/src/app/components/results-menu/results-menu.component.html b/src/app/components/results-menu/results-menu.component.html index f7514c19b..da8b7b672 100644 --- a/src/app/components/results-menu/results-menu.component.html +++ b/src/app/components/results-menu/results-menu.component.html @@ -45,7 +45,7 @@ [resize$]="resize$"> - +
- +
diff --git a/src/app/components/results-menu/timeseries-results-menu/timeseries-results-menu.component.scss b/src/app/components/results-menu/timeseries-results-menu/timeseries-results-menu.component.scss index 40cbde705..f139c7dc7 100644 --- a/src/app/components/results-menu/timeseries-results-menu/timeseries-results-menu.component.scss +++ b/src/app/components/results-menu/timeseries-results-menu/timeseries-results-menu.component.scss @@ -5,7 +5,7 @@ .ts-chart-row { display: flex; flex-direction: row; - height: calc(100% - 137px); + height: calc(100%); } .ts-chart-card { diff --git a/src/app/components/results-menu/timeseries-results-menu/timeseries-results-menu.component.ts b/src/app/components/results-menu/timeseries-results-menu/timeseries-results-menu.component.ts index 8aa9938df..6314d7f94 100644 --- a/src/app/components/results-menu/timeseries-results-menu/timeseries-results-menu.component.ts +++ b/src/app/components/results-menu/timeseries-results-menu/timeseries-results-menu.component.ts @@ -45,6 +45,7 @@ export class TimeseriesResultsMenuComponent implements OnInit, OnDestroy { public pointHistory = []; + constructor( private store$: Store, private screenSize: ScreenSizeService, diff --git a/src/app/components/timeseries-chart/timeseries-chart.component.html b/src/app/components/timeseries-chart/timeseries-chart.component.html index 2409d7423..f94819558 100644 --- a/src/app/components/timeseries-chart/timeseries-chart.component.html +++ b/src/app/components/timeseries-chart/timeseries-chart.component.html @@ -1,2 +1,4 @@ -
\ No newline at end of file +
+
+
\ No newline at end of file diff --git a/src/app/components/timeseries-chart/timeseries-chart.component.scss b/src/app/components/timeseries-chart/timeseries-chart.component.scss index b0627adec..f04b13e86 100644 --- a/src/app/components/timeseries-chart/timeseries-chart.component.scss +++ b/src/app/components/timeseries-chart/timeseries-chart.component.scss @@ -1,12 +1,22 @@ @import "asf-theme"; #timeseriesChart { - height: 460px; - width: 680px; + // height: 460px; + // width: 680px; } ::ng-deep .timeseries-base { @include themify($themes) { fill: lighten(themed('dark-primary-text'), 45%); } - } \ No newline at end of file + } + +.chart-wrapper { + height: calc(100% - 1px); + width: calc(50% - 30px); +} + +#timeseriesChart { + height: 100%; + width: 100%; +} \ No newline at end of file diff --git a/src/app/components/timeseries-chart/timeseries-chart.component.ts b/src/app/components/timeseries-chart/timeseries-chart.component.ts index 33bf9b67d..2b4fb2049 100644 --- a/src/app/components/timeseries-chart/timeseries-chart.component.ts +++ b/src/app/components/timeseries-chart/timeseries-chart.component.ts @@ -1,8 +1,9 @@ -import { Component, OnInit } from '@angular/core'; +import { Component, ElementRef, Input, OnInit, ViewChild } from '@angular/core'; import { NetcdfService } from '@services'; // import * as models from '@models'; import * as d3 from 'd3'; +import { Observable } from 'rxjs'; @Component({ selector: 'app-timeseries-chart', @@ -10,6 +11,10 @@ import * as d3 from 'd3'; styleUrl: './timeseries-chart.component.scss' }) export class TimeseriesChartComponent implements OnInit { + @ViewChild('timeseriesChart', { static: true }) timeseriesChart: ElementRef; + @Input() zoomIn$: Observable; + @Input() zoomOut$: Observable; + @Input() zoomToFit$: Observable; public json_data: string = ''; private svg?: any; public dataSource = []; @@ -26,7 +31,7 @@ export class TimeseriesChartComponent implements OnInit { private yAxis; private dots; private margin = { top: 10, right: 30, bottom: 60, left: 20 }; - + private thing @@ -37,16 +42,23 @@ export class TimeseriesChartComponent implements OnInit { public ngOnInit(): void { - this.svg = d3.select('#timeseriesChart').append('svg') - .attr('width', this.width + this.margin.left + this.margin.right) - .attr('height', this.height + this.margin.top + this.margin.bottom) - .append('g') - .attr('transform', `translate(${this.margin.left}, ${this.margin.top})`); - this.drawChart(); + // this.svg = d3.select('#timeseriesChart').append('svg') + // .attr('width', this.width + this.margin.left + this.margin.right) + // .attr('height', this.height + this.margin.top + this.margin.bottom) + // .append('g') + // .attr('transform', `translate(${this.margin.left}, ${this.margin.top})`); + // this.drawChart(); + this.createSVG(); - this.netcdfService.getTimeSeries({'lon': 0, 'lat': 0}).subscribe(data => { - this.initChart(data); - }) + this.netcdfService.getTimeSeries({'lon': 0, 'lat': 0}).subscribe(data => { + this.initChart(data); + }) + this.zoomOut$.subscribe(_ => { + this.thing.transition().call(this.zoom.scaleBy, .5); + }); + this.zoomIn$.subscribe(_ => { + this.thing.transition().call(this.zoom.scaleBy, 2); + }); } public initChart(data): void { @@ -94,7 +106,8 @@ export class TimeseriesChartComponent implements OnInit { this.currentTransform = eve.transform; this.updateChart(); }); - d3.select('#timeseriesChart').selectChild().call(this.zoom) + this.thing = d3.select('#timeseriesChart').selectChild() + this.thing.call(this.zoom) this.svg.append('defs').append('SVG:clipPath') .attr('id', 'clip') @@ -141,5 +154,23 @@ export class TimeseriesChartComponent implements OnInit { public updateAxis(_axis, _value) { } + public onResized() { + this.createSVG(); + } + + private createSVG() { + if (this.svg) { + d3.selectAll('#timeseries-chart > svg').remove(); + d3.selectAll('.tooltip').remove(); + } + this.height = this.timeseriesChart.nativeElement.offsetHeight - this.margin.top - this.margin.bottom; + this.width = this.timeseriesChart.nativeElement.offsetWidth - this.margin.left - this.margin.right; + this.svg = d3.select(this.timeseriesChart.nativeElement).append('svg') + .attr('width', this.width + this.margin.left + this.margin.right) + .attr('height', this.height + this.margin.top + this.margin.bottom) + .append('g') + .attr('transform', `translate(${this.margin.left}, ${this.margin.top})`); + this.drawChart(); + } }