[Code Review] Updates based on code review by @VWoeltjen

Set export functions on the ExportImageService prototype. Insantiated
ExportImageService in the PlotController for better dependcy injection.
This commit is contained in:
David Hudson
2016-09-02 11:54:38 +09:00
parent 3a19890be9
commit e370271093
3 changed files with 13 additions and 24 deletions

View File

@ -250,6 +250,7 @@ define(
self.pending = true;
self.$element = $element;
self.ExportImageService = new ExportImageService();
// Initialize axes; will get repopulated when telemetry
// metadata becomes available.
@ -258,18 +259,6 @@ define(
new PlotAxis("ranges", [], AXIS_DEFAULTS[1])
];
$scope.exportPDF = function () {
PlotController.prototype.exportPDF(self.$element, 'plot.pdf');
};
$scope.exportPNG = function () {
PlotController.prototype.exportPNG(self.$element, 'plot.png');
};
$scope.exportJPG = function () {
PlotController.prototype.exportJPG(self.$element, 'plot.jpg');
};
// Watch for changes to the selected axis
$scope.$watch("axes[0].active.key", domainRequery);
$scope.$watch("axes[1].active.key", rangeRequery);
@ -383,22 +372,22 @@ define(
/**
* Export the plot to PDF
*/
PlotController.prototype.exportPDF = function (element, filename) {
ExportImageService.exportPDF(element[0], filename);
PlotController.prototype.exportPDF = function () {
this.ExportImageService.exportPDF(this.$element[0], 'plot.pdf');
};
/**
* Export the plot to PNG
*/
PlotController.prototype.exportPNG = function (element, filename) {
ExportImageService.exportPNG(element, filename);
PlotController.prototype.exportPNG = function () {
this.ExportImageService.exportPNG(this.$element[0], 'plot.png');
};
/**
* Export the plot to JPG
*/
PlotController.prototype.exportJPG = function (element, filename) {
ExportImageService.exportJPG(element, filename);
PlotController.prototype.exportJPG = function () {
this.ExportImageService.exportJPG(this.$element[0], 'plot.jpg');
};
return PlotController;