mirror of
https://github.com/grafana/grafana.git
synced 2026-07-30 00:08:10 -05:00
Dataplane: Support timeSeriesLong without transform (#62732)
* support timeSeriesLong without transform * move timeserieslong transform to the right spot * add review suggestions for using types and moving options inline * handle frames with different field names * remove extra options
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import {
|
||||
ArrayVector,
|
||||
DataFrame,
|
||||
DataFrameType,
|
||||
Field,
|
||||
FieldType,
|
||||
getDisplayProcessor,
|
||||
@@ -14,6 +15,7 @@ import {
|
||||
import { GraphFieldConfig, LineInterpolation } from '@grafana/schema';
|
||||
import { applyNullInsertThreshold } from '@grafana/ui/src/components/GraphNG/nullInsertThreshold';
|
||||
import { nullToValue } from '@grafana/ui/src/components/GraphNG/nullToValue';
|
||||
import { partitionByValuesTransformer } from 'app/features/transformers/partitionByValues/partitionByValues';
|
||||
|
||||
/**
|
||||
* Returns null if there are no graphable fields
|
||||
@@ -27,6 +29,10 @@ export function prepareGraphableFields(
|
||||
return null;
|
||||
}
|
||||
|
||||
if (series.every((df) => df.meta?.type === DataFrameType.TimeSeriesLong)) {
|
||||
series = prepareTimeSeriesLong(series);
|
||||
}
|
||||
|
||||
let copy: Field;
|
||||
|
||||
const frames: DataFrame[] = [];
|
||||
@@ -173,3 +179,20 @@ export function regenerateLinksSupplier(
|
||||
|
||||
return alignedDataFrame;
|
||||
}
|
||||
|
||||
export function prepareTimeSeriesLong(series: DataFrame[]): DataFrame[] {
|
||||
// Transform each dataframe of the series
|
||||
// to handle different field names in different frames
|
||||
return series.reduce((acc: DataFrame[], dataFrame: DataFrame) => {
|
||||
// these could be different in each frame
|
||||
const stringFields = dataFrame.fields.filter((field) => field.type === FieldType.string).map((field) => field.name);
|
||||
|
||||
// transform one dataFrame at a time and concat into DataFrame[]
|
||||
const transformedSeries = partitionByValuesTransformer.transformer(
|
||||
{ fields: stringFields },
|
||||
{ interpolate: (value: string) => value }
|
||||
)([dataFrame]);
|
||||
|
||||
return acc.concat(transformedSeries);
|
||||
}, []);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user