mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
grafana/data: Move data frames processing functions from core (#60795)
This commit is contained in:
@@ -19,6 +19,7 @@ import {
|
|||||||
DataFrameDTO,
|
DataFrameDTO,
|
||||||
TIME_SERIES_VALUE_FIELD_NAME,
|
TIME_SERIES_VALUE_FIELD_NAME,
|
||||||
TIME_SERIES_TIME_FIELD_NAME,
|
TIME_SERIES_TIME_FIELD_NAME,
|
||||||
|
DataQueryResponseData,
|
||||||
} from '../types/index';
|
} from '../types/index';
|
||||||
import { ArrayVector } from '../vector/ArrayVector';
|
import { ArrayVector } from '../vector/ArrayVector';
|
||||||
import { SortedVector } from '../vector/SortedVector';
|
import { SortedVector } from '../vector/SortedVector';
|
||||||
@@ -510,3 +511,29 @@ export const getTimeField = (series: DataFrame): { timeField?: Field; timeIndex?
|
|||||||
}
|
}
|
||||||
return {};
|
return {};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function getProcessedDataFrame(data: DataQueryResponseData): DataFrame {
|
||||||
|
const dataFrame = guessFieldTypes(toDataFrame(data));
|
||||||
|
|
||||||
|
if (dataFrame.fields && dataFrame.fields.length) {
|
||||||
|
// clear out the cached info
|
||||||
|
for (const field of dataFrame.fields) {
|
||||||
|
field.state = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return dataFrame;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Given data request results, will return data frames with field types set
|
||||||
|
*
|
||||||
|
* This is also used by PanelChrome for snapshot support
|
||||||
|
*/
|
||||||
|
export function getProcessedDataFrames(results?: DataQueryResponseData[]): DataFrame[] {
|
||||||
|
if (!results || !isArray(results)) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
return results.map((data) => getProcessedDataFrame(data));
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,8 +1,14 @@
|
|||||||
import { applyFieldOverrides, ArrayDataFrame, getDefaultTimeRange, LoadingState, PanelData } from '@grafana/data';
|
import {
|
||||||
|
applyFieldOverrides,
|
||||||
|
ArrayDataFrame,
|
||||||
|
getDefaultTimeRange,
|
||||||
|
getProcessedDataFrames,
|
||||||
|
LoadingState,
|
||||||
|
PanelData,
|
||||||
|
} from '@grafana/data';
|
||||||
import { config } from 'app/core/config';
|
import { config } from 'app/core/config';
|
||||||
|
|
||||||
import { SnapshotWorker } from '../../query/state/DashboardQueryRunner/SnapshotWorker';
|
import { SnapshotWorker } from '../../query/state/DashboardQueryRunner/SnapshotWorker';
|
||||||
import { getProcessedDataFrames } from '../../query/state/runRequest';
|
|
||||||
import { getTimeSrv } from '../services/TimeSrv';
|
import { getTimeSrv } from '../services/TimeSrv';
|
||||||
import { DashboardModel, PanelModel } from '../state';
|
import { DashboardModel, PanelModel } from '../state';
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,14 @@
|
|||||||
import { from, of, OperatorFunction } from 'rxjs';
|
import { from, of, OperatorFunction } from 'rxjs';
|
||||||
import { map, mergeMap } from 'rxjs/operators';
|
import { map, mergeMap } from 'rxjs/operators';
|
||||||
|
|
||||||
import { FieldType, getFieldDisplayName, isDataFrame, MetricFindValue, PanelData } from '@grafana/data';
|
import {
|
||||||
import { getProcessedDataFrames } from 'app/features/query/state/runRequest';
|
FieldType,
|
||||||
|
getFieldDisplayName,
|
||||||
|
getProcessedDataFrames,
|
||||||
|
isDataFrame,
|
||||||
|
MetricFindValue,
|
||||||
|
PanelData,
|
||||||
|
} from '@grafana/data';
|
||||||
|
|
||||||
import { ThunkDispatch } from '../../../types';
|
import { ThunkDispatch } from '../../../types';
|
||||||
import { validateVariableSelectionState } from '../state/actions';
|
import { validateVariableSelectionState } from '../state/actions';
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { getProcessedDataFrames } from 'app/features/query/state/runRequest';
|
import { getProcessedDataFrames } from '@grafana/data';
|
||||||
|
|
||||||
import { DataProcessor } from '../data_processor';
|
import { DataProcessor } from '../data_processor';
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user