mirror of
https://github.com/grafana/grafana.git
synced 2025-01-16 03:32:37 -06:00
grafana/data: Move data frames processing functions from core (#60795)
This commit is contained in:
parent
aa0936127d
commit
78d7f11b8e
@ -19,6 +19,7 @@ import {
|
||||
DataFrameDTO,
|
||||
TIME_SERIES_VALUE_FIELD_NAME,
|
||||
TIME_SERIES_TIME_FIELD_NAME,
|
||||
DataQueryResponseData,
|
||||
} from '../types/index';
|
||||
import { ArrayVector } from '../vector/ArrayVector';
|
||||
import { SortedVector } from '../vector/SortedVector';
|
||||
@ -510,3 +511,29 @@ export const getTimeField = (series: DataFrame): { timeField?: Field; timeIndex?
|
||||
}
|
||||
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 { SnapshotWorker } from '../../query/state/DashboardQueryRunner/SnapshotWorker';
|
||||
import { getProcessedDataFrames } from '../../query/state/runRequest';
|
||||
import { getTimeSrv } from '../services/TimeSrv';
|
||||
import { DashboardModel, PanelModel } from '../state';
|
||||
|
||||
|
@ -1,8 +1,14 @@
|
||||
import { from, of, OperatorFunction } from 'rxjs';
|
||||
import { map, mergeMap } from 'rxjs/operators';
|
||||
|
||||
import { FieldType, getFieldDisplayName, isDataFrame, MetricFindValue, PanelData } from '@grafana/data';
|
||||
import { getProcessedDataFrames } from 'app/features/query/state/runRequest';
|
||||
import {
|
||||
FieldType,
|
||||
getFieldDisplayName,
|
||||
getProcessedDataFrames,
|
||||
isDataFrame,
|
||||
MetricFindValue,
|
||||
PanelData,
|
||||
} from '@grafana/data';
|
||||
|
||||
import { ThunkDispatch } from '../../../types';
|
||||
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';
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user