diff --git a/public/app/plugins/panel/graph/data_processor.ts b/public/app/plugins/panel/graph/data_processor.ts index 2966bb33eb4..f148cc9e0b3 100644 --- a/public/app/plugins/panel/graph/data_processor.ts +++ b/public/app/plugins/panel/graph/data_processor.ts @@ -2,11 +2,17 @@ import _ from 'lodash'; import { colors, getColorFromHexRgbOrName } from '@grafana/ui'; import TimeSeries from 'app/core/time_series2'; import config from 'app/core/config'; +import { LegacyResponseData, TimeRange } from '@grafana/ui'; + +type Options = { + dataList: LegacyResponseData[]; + range?: TimeRange; +}; export class DataProcessor { constructor(private panel) {} - getSeriesList(options) { + getSeriesList(options: Options): TimeSeries[] { if (!options.dataList || options.dataList.length === 0) { return []; } @@ -49,6 +55,8 @@ export class DataProcessor { return this.customHandler(firstItem); } } + + return []; } getAutoDetectXAxisMode(firstItem) { @@ -102,7 +110,7 @@ export class DataProcessor { } } - timeSeriesHandler(seriesData, index, options) { + timeSeriesHandler(seriesData: LegacyResponseData, index: number, options: Options) { const datapoints = seriesData.datapoints || []; const alias = seriesData.target; @@ -120,7 +128,8 @@ export class DataProcessor { if (datapoints && datapoints.length > 0) { const last = datapoints[datapoints.length - 1][1]; const from = options.range.from; - if (last - from < -10000) { + + if (last - from.valueOf() < -10000) { series.isOutsideRange = true; } } diff --git a/public/app/plugins/panel/graph/module.ts b/public/app/plugins/panel/graph/module.ts index 9ac148a42cd..5a8789ed5d2 100644 --- a/public/app/plugins/panel/graph/module.ts +++ b/public/app/plugins/panel/graph/module.ts @@ -10,15 +10,16 @@ import { MetricsPanelCtrl } from 'app/plugins/sdk'; import { DataProcessor } from './data_processor'; import { axesEditorComponent } from './axes_editor'; import config from 'app/core/config'; -import { getColorFromHexRgbOrName } from '@grafana/ui'; +import TimeSeries from 'app/core/time_series2'; +import { getColorFromHexRgbOrName, LegacyResponseData } from '@grafana/ui'; class GraphCtrl extends MetricsPanelCtrl { static template = template; renderError: boolean; hiddenSeries: any = {}; - seriesList: any = []; - dataList: any = []; + seriesList: TimeSeries[] = []; + dataList: LegacyResponseData[] = []; annotations: any = []; alertState: any; @@ -186,7 +187,7 @@ class GraphCtrl extends MetricsPanelCtrl { this.render([]); } - onDataReceived(dataList) { + onDataReceived(dataList: LegacyResponseData[]) { this.dataList = dataList; this.seriesList = this.processor.getSeriesList({ dataList: dataList,