Skip to content
This repository has been archived by the owner on Aug 21, 2023. It is now read-only.

Commit

Permalink
Merge pull request #121 from azavea/feature/FixLab
Browse files Browse the repository at this point in the history
Feature/fix lab
  • Loading branch information
fungjj92 authored Dec 30, 2016
2 parents 81bb501 + e283776 commit 118cd09
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 17 deletions.
5 changes: 4 additions & 1 deletion src/app/charts/chart.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,10 @@ export class ChartComponent implements OnChanges {
indicator: this.chart.indicator,
scenario: this.scenario,
city: this.city,
climateModels: this.models
climateModels: this.models,
// As a temporary solution, the time agg defaults to the 1st valid option.
// Really, this should a user selectable option
time_aggregation: this.chart.indicator.valid_aggregations[0]
}).subscribe(data => this.chartData = this.chartService.convertChartData([data]));
}

Expand Down
4 changes: 2 additions & 2 deletions src/app/charts/line-graph.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export class LineGraphComponent implements OnInit, OnDestroy {
ngOnInit(): void {
// Set up global chart mouseover communication chain if set to multi-chart scrubber
// ** CURRENTLY ONLY FOR YEARLY INDICATORS**
if (this.multiChartScrubber && this.indicator.time_aggregation === 'yearly') {
if (this.multiChartScrubber && this.data[0].time_aggregation === 'yearly') {
this.multiChartScrubberHoverSubscription = this.chartService.multiChartScrubberHoverObservable.subscribe(data => {
this.hover = data;
this.hover ? $('.' + this.id).toggleClass('hidden', false) : $('.' + this.id).toggleClass('hidden', true);
Expand All @@ -116,7 +116,7 @@ export class LineGraphComponent implements OnInit, OnDestroy {
}

ngOnDestroy(): void {
if (this.multiChartScrubber && this.indicator.time_aggregation === 'yearly') {
if (this.multiChartScrubber && this.data[0].time_aggregation === 'yearly') {
this.multiChartScrubberInfoSubscription.unsubscribe();
this.multiChartScrubberHoverSubscription.unsubscribe();
}
Expand Down
14 changes: 11 additions & 3 deletions src/app/models/chart-data.model.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
import { MultiDataPoint } from './multi-data-point.model';
import { Indicator } from './indicator.model';
import { City } from './city.model';
import { ClimateModel } from './climate-model.model';
import { Scenario } from './scenario.model';

export class ChartData {
indicator: string;
indicator: Indicator;
data: MultiDataPoint[];
time_agg: string[];
time_aggregation: string;
time_format: string;
}
city?: City;
climate_models?: ClimateModel[];
scenario?: Scenario;
units?: string
}
3 changes: 2 additions & 1 deletion src/app/models/indicator-query-opts.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ export interface IndicatorQueryOpts {
scenario: Scenario;
climateModels?: ClimateModel[];
years?: string[];
}
time_aggregation?: string;
}
5 changes: 4 additions & 1 deletion src/app/models/indicator.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,8 @@ export class Indicator {
description: string;
time_aggregation: string;
variables: string[];
available_units?: string[];
default_units?: string;
parameters?: any[];
valid_aggregations?: string[];
}

4 changes: 2 additions & 2 deletions src/app/services/chart.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export class ChartService {
_.each(data, obj => {
let indicatorData: MultiDataPoint[] = [];
let indicator = obj.indicator;
let timeFormat = this.timeOptions[indicator.time_aggregation];
let timeFormat = this.timeOptions[obj.time_aggregation];
let parseTime = D3.timeParse(timeFormat);

_.each(obj.data, (values, key) => {
Expand All @@ -75,7 +75,7 @@ export class ChartService {
chartData.push({
'indicator': indicator,
'data': indicatorData,
'time_agg': indicator.time_aggregation,
'time_aggregation': obj.time_aggregation,
'time_format': timeFormat
} as ChartData);
}
Expand Down
3 changes: 3 additions & 0 deletions src/app/services/indicator.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ export class IndicatorService {
if (options.climateModels) {
searchParams.append('models', options.climateModels.map(m => m.name).join(','));
}
if (options.time_aggregation) {
searchParams.append('time_aggregation', options.time_aggregation);
}

let requestOptions = new RequestOptions({search: searchParams});
return this.apiHttp.get(url, requestOptions).map(resp => resp.json());
Expand Down
9 changes: 2 additions & 7 deletions src/app/sidebar/sidebar.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,10 @@ export class SidebarComponent implements OnInit {

private groupIndicators(indicators: Indicator[]) {
this.tempIndicators = indicators.filter(i => {
return this.isValidIndicator(i) &&
(i.variables.indexOf('tasmax') !== -1 || i.variables.indexOf('tasmin') !== -1);
return (i.variables.indexOf('tasmax') !== -1 || i.variables.indexOf('tasmin') !== -1);
});
this.precipIndicators = indicators.filter(i => {
return this.isValidIndicator(i) && i.variables.indexOf('pr') !== -1;
return i.variables.indexOf('pr') !== -1;
});
}

private isValidIndicator(indicator: Indicator): boolean {
return indicator.time_aggregation !== 'daily';
}
}

0 comments on commit 118cd09

Please sign in to comment.