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
pull/63806/head
Brendan O'Handley 3 years ago committed by GitHub
parent 2eba37b95b
commit 79c9ab1952
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 23
      public/app/plugins/panel/timeseries/utils.ts

@ -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);
}, []);
}

Loading…
Cancel
Save