diff --git a/src/ui/databrowserModule/fileviewer/chart.interface.ts b/src/ui/databrowserModule/fileviewer/chart.interface.ts index 4a1371704fa6515fb8f0226ff5d2b0f51debd94b..300eca5c2859e6fd4a47ff1ce8f35f3584c36f0f 100644 --- a/src/ui/databrowserModule/fileviewer/chart.interface.ts +++ b/src/ui/databrowserModule/fileviewer/chart.interface.ts @@ -1,6 +1,8 @@ import { ChartOptions } from "chart.js"; import merge from 'lodash.merge' +import { SafeUrl } from "@angular/platform-browser"; +import { ElementRef } from "@angular/core"; export interface ScaleOptionInterface{ type? : string @@ -69,6 +71,14 @@ export interface ScaleLabelInterface{ display? : boolean } +export interface CommonChartInterface{ + csvDataUrl: SafeUrl + csvTitle: string + imageTitle: string + + canvas: ElementRef +} + export const applyOption = (defaultOption:ChartOptions,option?:Partial<ChartOptions>)=>{ merge(defaultOption,option) } \ No newline at end of file diff --git a/src/ui/databrowserModule/fileviewer/fileviewer.component.ts b/src/ui/databrowserModule/fileviewer/fileviewer.component.ts index edaeafad745cddce950087e0fa8e052fb6dc3d45..37eaa626f0225b4b2416fffb9a1366c03a88a9ee 100644 --- a/src/ui/databrowserModule/fileviewer/fileviewer.component.ts +++ b/src/ui/databrowserModule/fileviewer/fileviewer.component.ts @@ -2,6 +2,7 @@ import { Component, Input, ViewChild, ElementRef, Inject, Optional, OnChanges } import { ViewerPreviewFile } from 'src/services/state/dataStore.store'; import { MAT_DIALOG_DATA } from '@angular/material'; +import { CommonChartInterface } from './chart.interface'; @Component({ @@ -18,7 +19,7 @@ export class FileViewer implements OnChanges{ */ @Input() previewFile : ViewerPreviewFile - @ViewChild('childChart') childChart : ChartComponentInterface + @ViewChild('childChart') childChart: CommonChartInterface constructor( @Optional() @Inject(MAT_DIALOG_DATA) data @@ -31,9 +32,3 @@ export class FileViewer implements OnChanges{ this.downloadUrl = this.previewFile.url } } - -interface ChartComponentInterface{ - canvas : ElementRef, - shapedLineChartDatasets: any -} - diff --git a/src/ui/databrowserModule/fileviewer/fileviewer.template.html b/src/ui/databrowserModule/fileviewer/fileviewer.template.html index 35cc94aaee688c5c42cd6ca889ac6e92fcfc7cb5..99fdf6575ba87a959a529ca4a9b3e30321f0d94a 100644 --- a/src/ui/databrowserModule/fileviewer/fileviewer.template.html +++ b/src/ui/databrowserModule/fileviewer/fileviewer.template.html @@ -23,7 +23,7 @@ <div [ngSwitch]="previewFile.data.chartType" *ngSwitchCase="'application/json'"> <radar-chart - #childChart + #childChart="iavRadarChart" [colors]="previewFile.data.colors" [options]="previewFile.data.chartOptions" [labels]="previewFile.data.labels" diff --git a/src/ui/databrowserModule/fileviewer/line/line.chart.component.ts b/src/ui/databrowserModule/fileviewer/line/line.chart.component.ts index 564b19f6811ca7a0a599a598f27bbee2c22281be..6e456f4808f674638852c2416edbef4981ac232d 100644 --- a/src/ui/databrowserModule/fileviewer/line/line.chart.component.ts +++ b/src/ui/databrowserModule/fileviewer/line/line.chart.component.ts @@ -1,9 +1,10 @@ import { Component, Input, OnChanges, ElementRef, ViewChild } from '@angular/core' -import { DatasetInterface, ChartColor, ScaleOptionInterface, LegendInterface, TitleInterfacce, applyOption } from '../chart.interface' +import { DatasetInterface, ChartColor, ScaleOptionInterface, LegendInterface, TitleInterfacce, applyOption, CommonChartInterface } from '../chart.interface' import { ChartOptions, LinearTickOptions,ChartDataSets } from 'chart.js'; import { Color } from 'ng2-charts'; import { DomSanitizer, SafeUrl } from '@angular/platform-browser'; + @Component({ selector : `line-chart`, templateUrl : './line.chart.template.html', @@ -12,7 +13,7 @@ import { DomSanitizer, SafeUrl } from '@angular/platform-browser'; ], exportAs: 'iavLineChart' }) -export class LineChart implements OnChanges{ +export class LineChart implements OnChanges, CommonChartInterface{ @ViewChild('canvas') canvas: ElementRef diff --git a/src/ui/databrowserModule/fileviewer/radar/radar.chart.component.ts b/src/ui/databrowserModule/fileviewer/radar/radar.chart.component.ts index 2eaad28d926c74e30efbebf433508de54c8b646b..2b97314d9f3911cf39c6ec2ddd78f9de07677e8b 100644 --- a/src/ui/databrowserModule/fileviewer/radar/radar.chart.component.ts +++ b/src/ui/databrowserModule/fileviewer/radar/radar.chart.component.ts @@ -1,6 +1,6 @@ import { Component, Input, OnChanges, ViewChild, ElementRef } from '@angular/core' -import { DatasetInterface, ChartColor, ScaleOptionInterface, TitleInterfacce, LegendInterface, applyOption } from '../chart.interface'; +import { DatasetInterface, ChartColor, ScaleOptionInterface, TitleInterfacce, LegendInterface, applyOption, CommonChartInterface } from '../chart.interface'; import { Color } from 'ng2-charts'; import { SafeUrl, DomSanitizer } from '@angular/platform-browser'; import { RadialChartOptions } from 'chart.js' @@ -11,8 +11,9 @@ import { RadialChartOptions } from 'chart.js' styleUrls : [ `./radar.chart.style.css` ], + exportAs: 'iavRadarChart' }) -export class RadarChart implements OnChanges{ +export class RadarChart implements OnChanges, CommonChartInterface{ @ViewChild('canvas') canvas : ElementRef /**