diff --git a/CHANGELOG.md b/CHANGELOG.md index 4a514bde3..dcb46e29d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [Unreleased] ### Added - Added ability to remove users from an organization to the settings page + - Added ability for users to download charts as PNGs ### Fixed - Fixed bug where organization dropdown could be shown to a user with no organizations - Fixed a bug where users can invite the same user to their organization twice. diff --git a/src/angular/planit/package.json b/src/angular/planit/package.json index 3a9d528e8..18ab040af 100644 --- a/src/angular/planit/package.json +++ b/src/angular/planit/package.json @@ -26,7 +26,7 @@ "@angular/router": "~4.4.5", "bootstrap": "^3.3.7", "bootstrap-sass": "^3.3.7", - "climate-change-components": "0.3.1", + "climate-change-components": "0.4.0", "core-js": "^2.4.1", "difflib": "^0.2.4", "inert-polyfill": "^0.2.5", diff --git a/src/angular/planit/src/app/shared/chart/chart.component.html b/src/angular/planit/src/app/shared/chart/chart.component.html index b7f8ccfca..f32b89c4a 100644 --- a/src/angular/planit/src/app/shared/chart/chart.component.html +++ b/src/angular/planit/src/app/shared/chart/chart.component.html @@ -51,5 +51,17 @@ Derived from the NASA Earth Exchange Global Daily Downscaled Projections (NEX-GDDP) dataset. Data available at https://nex.nasa.gov/nex/projects/1356/. Downscaled from CMIP5, using the Localized Constructed Analogs (LOCA) statistical technique. Data available at loca.ucsd.edu. + +
diff --git a/src/angular/planit/src/app/shared/chart/chart.component.ts b/src/angular/planit/src/app/shared/chart/chart.component.ts index 27a63c44e..51d401ee3 100644 --- a/src/angular/planit/src/app/shared/chart/chart.component.ts +++ b/src/angular/planit/src/app/shared/chart/chart.component.ts @@ -16,14 +16,16 @@ import { ChartData, ChartService, ClimateModel, + DataExportService, Dataset, + ImageExportService, Indicator, IndicatorDistanceQueryParams, IndicatorQueryParams, IndicatorRequestOpts, IndicatorService, Scenario, - TimeAggParam + TimeAggParam, } from 'climate-change-components'; import { environment } from '../../../environments/environment'; @@ -35,7 +37,11 @@ import { Point } from '../geojson'; */ @Component({ selector: 'app-chart', - templateUrl: './chart.component.html' + templateUrl: './chart.component.html', + providers: [ + DataExportService, + ImageExportService + ] }) export class ChartComponent implements OnChanges, OnDestroy, OnInit { @@ -85,6 +91,8 @@ export class ChartComponent implements OnChanges, OnDestroy, OnInit { private dataSubscription: Subscription; constructor(private chartService: ChartService, + private dataExportService: DataExportService, + private imageExportService: ImageExportService, private indicatorService: IndicatorService) {} // Mousemove event must be at this level to listen to mousing over rect#overlay @@ -166,6 +174,15 @@ export class ChartComponent implements OnChanges, OnDestroy, OnInit { }); } + onDownloadImageClicked() { + const fileName: string = [ + this.indicator.name, + this.dataset.name, + this.scenario.name + ].join('_'); + this.imageExportService.downloadAsPNG(this.indicator.name, fileName, 'app-chart'); + } + public onExtraParamsSelected(params: IndicatorQueryParams) { this.extraParams = params; this.extraParamsChanged.emit(this.extraParams);