|
|
|
@ -1,6 +1,8 @@
|
|
|
|
|
import { PanelData, TimeRange } from '@grafana/data'; |
|
|
|
|
import { DataProcessor } from '../grafana/data_processor'; |
|
|
|
|
|
|
|
|
|
import { ExtremumOptions } from 'types'; |
|
|
|
|
|
|
|
|
|
import * as _ from 'lodash'; |
|
|
|
|
|
|
|
|
|
// Convert Grafana options into Chartwerk options
|
|
|
|
@ -8,17 +10,22 @@ export class Series {
|
|
|
|
|
private processor;
|
|
|
|
|
private _seriesList; |
|
|
|
|
|
|
|
|
|
constructor(private grafanaData: PanelData, timeRange: TimeRange) { |
|
|
|
|
constructor(private grafanaData: PanelData, timeRange: TimeRange, private gaugeValueOptions: ExtremumOptions) { |
|
|
|
|
if(this._isSerieOneValue()) { |
|
|
|
|
this._seriesList = [{ datapoints: [[0, gaugeValueOptions.value]] }]; |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
this.processor = new DataProcessor({}); |
|
|
|
|
const seriesList = this.processor.getSeriesList({ |
|
|
|
|
this._seriesList = this.processor.getSeriesList({ |
|
|
|
|
dataList: grafanaData.series, |
|
|
|
|
range: timeRange, |
|
|
|
|
}); |
|
|
|
|
this._seriesList = this._updateSeriesListWithChartwerkParams(seriesList); |
|
|
|
|
this._seriesList = this._updateSeriesListWithChartwerkParams(this._seriesList); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public getChartwerkSeries(): any[] { |
|
|
|
|
return this._seriesList; |
|
|
|
|
return this._seriesList |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private _updateSeriesListWithChartwerkParams(series: any[]): any[] { |
|
|
|
@ -31,4 +38,8 @@ export class Series {
|
|
|
|
|
}; |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private _isSerieOneValue(): boolean { |
|
|
|
|
return _.isNumber(this.gaugeValueOptions.value); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|