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

Commit

Permalink
Merge pull request #1210 from azavea/feature/dpd/add-chart-png-export
Browse files Browse the repository at this point in the history
Add PNG Chart export
  • Loading branch information
ddohler authored Apr 3, 2019
2 parents a84c4bd + 392945c commit 567895c
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion src/angular/planit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
12 changes: 12 additions & 0 deletions src/angular/planit/src/app/shared/chart/chart.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,17 @@
<span *ngIf="dataset.name === 'NEX-GDDP'">Derived from the NASA Earth Exchange Global Daily Downscaled Projections (NEX-GDDP) dataset. Data available at <a target="_blank" href="https://nex.nasa.gov/nex/projects/1356/">https://nex.nasa.gov/nex/projects/1356/<i class="icon-link-ext-alt"></i></a>.</span>
<span *ngIf="dataset.name === 'LOCA'">Downscaled from CMIP5, using the Localized Constructed Analogs (LOCA) statistical technique. Data available at <a target="_blank" href="http://loca.ucsd.edu">loca.ucsd.edu<i class="icon-link-ext-alt"></i></a>.</span>
</div>

<div class="chart-options buttons">
<div class="chart-options-body">
<div class="chart-options-group btn-group">
<button class="button" type="button"
id="exportDropUp" (click)="onDownloadImageClicked()">
<i class="icon icon-download"></i>
Download
</button>
</div>
</div>
</div>
</div>
</div>
21 changes: 19 additions & 2 deletions src/angular/planit/src/app/shared/chart/chart.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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 {

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 567895c

Please sign in to comment.