|
|
|
@ -1,22 +1,19 @@
|
|
|
|
|
import { PanelData, TimeRange } from '@grafana/data'; |
|
|
|
|
import { DataProcessor } from '../grafana/data_processor'; |
|
|
|
|
|
|
|
|
|
import { ExtremumOptions } from 'types'; |
|
|
|
|
import { ValueOptions } from 'types'; |
|
|
|
|
|
|
|
|
|
import * as _ from 'lodash'; |
|
|
|
|
|
|
|
|
|
// Convert Grafana options into Chartwerk options
|
|
|
|
|
|
|
|
|
|
// Convert Grafana series into Chartwerk series
|
|
|
|
|
export class Series { |
|
|
|
|
private processor;
|
|
|
|
|
private processor; |
|
|
|
|
private _seriesList; |
|
|
|
|
private _selectedSerieName; |
|
|
|
|
|
|
|
|
|
constructor(grafanaData: PanelData, timeRange: TimeRange, private gaugeValueOptions: ExtremumOptions) { |
|
|
|
|
if(this._isSerieOneValue()) { |
|
|
|
|
this._seriesList = [{ datapoints: [[0, gaugeValueOptions.value]] }]; |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
if(this.gaugeValueOptions.useMetric && _.isEmpty(this.gaugeValueOptions.metricName)) { |
|
|
|
|
constructor(grafanaData: PanelData, timeRange: TimeRange, private gaugeValueOptions: ValueOptions) { |
|
|
|
|
if(_.isEmpty(this.gaugeValueOptions.metricName)) { |
|
|
|
|
throw new Error(`Value or metric is not selected.`); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -52,8 +49,4 @@ export class Series {
|
|
|
|
|
}; |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private _isSerieOneValue(): boolean { |
|
|
|
|
return !this.gaugeValueOptions.useMetric; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|