rozetko
2 years ago
6 changed files with 102 additions and 11 deletions
@ -0,0 +1,25 @@
|
||||
import * as _ from 'lodash'; |
||||
|
||||
// Convert Grafana series into Chartwerk series
|
||||
export class BarSeries { |
||||
private _seriesList; |
||||
|
||||
constructor(grafanaSeriesList: any) { |
||||
this._seriesList = this._updateSeriesListWithChartwerkParams(grafanaSeriesList); |
||||
} |
||||
|
||||
getChartwerkSeries(): any[] { |
||||
return this._seriesList; |
||||
} |
||||
|
||||
private _updateSeriesListWithChartwerkParams(series: any[]): any[] { |
||||
return _.map(series, (serie: any, idx: number) => { |
||||
return { |
||||
target: serie.alias, |
||||
color: serie.color, |
||||
datapoints: _.map(serie.datapoints, (row) => _.reverse(_.clone(row))), |
||||
alias: serie.label, |
||||
}; |
||||
}); |
||||
} |
||||
} |
@ -0,0 +1,41 @@
|
||||
import { AbsoluteTimeRange } from '@grafana/data'; |
||||
|
||||
|
||||
// Convert Grafana options into Chartwerk Bar options
|
||||
export class BarOptions { |
||||
constructor(private grafanaSeriesList: any[], private changeTimeRange: (timeRange: AbsoluteTimeRange) => void) { |
||||
console.log(this.grafanaSeriesList) |
||||
} |
||||
|
||||
getChartwerkOptions(): any { |
||||
return { |
||||
axis: { |
||||
x: { |
||||
format: 'time', |
||||
}, |
||||
y: { |
||||
format: 'custom', |
||||
range: [-100, 100], |
||||
valueFormatter: (value: any) => { |
||||
return value + '%'; |
||||
}, |
||||
}, |
||||
}, |
||||
stacked: false, |
||||
matching: false, |
||||
zoomEvents: { |
||||
scroll: { zoom: { isActive: false }, pan: { isActive: false } }, |
||||
mouse: { doubleClick: { isActive: false } }, |
||||
}, |
||||
annotations: [ |
||||
{ key: 'm-1', color: 'red' }, |
||||
{ key: 'm-2', color: 'green' }, |
||||
], |
||||
eventsCallbacks: { |
||||
zoomIn: (range: any) => { |
||||
this.changeTimeRange({ from: range[0][0], to: range[0][1] }); |
||||
} |
||||
}, |
||||
}; |
||||
} |
||||
} |
@ -1,13 +1,13 @@
|
||||
import { PanelOptions, Aggregation, Threshold, Icon, IconPosition, Condition } from 'types'; |
||||
|
||||
import { filterMetricListByAlias, getAggregatedValueFromSerie } from '../utils'; |
||||
import { filterMetricListByAlias, getAggregatedValueFromSerie } from '../../utils'; |
||||
|
||||
import { getValueFormat } from '@grafana/data'; |
||||
|
||||
import _ from 'lodash'; |
||||
|
||||
// Convert Grafana options into Chartwerk Gauge options
|
||||
export class Options { |
||||
export class GaugeOptions { |
||||
private minValue: number | undefined; |
||||
private maxValue: number | undefined; |
||||
private thresholds: Array<{ value: number; color: string }> = []; |
Loading…
Reference in new issue