mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
TimeSeries: fix & optimize time string parsing (#64640)
This commit is contained in:
@@ -12,6 +12,7 @@ import {
|
||||
SortedVector,
|
||||
TimeRange,
|
||||
} from '@grafana/data';
|
||||
import { convertFieldType } from '@grafana/data/src/transformations/transformers/convertFieldType';
|
||||
import { GraphFieldConfig, LineInterpolation } from '@grafana/schema';
|
||||
import { applyNullInsertThreshold } from '@grafana/ui/src/components/GraphNG/nullInsertThreshold';
|
||||
import { nullToValue } from '@grafana/ui/src/components/GraphNG/nullToValue';
|
||||
@@ -29,6 +30,17 @@ export function prepareGraphableFields(
|
||||
return null;
|
||||
}
|
||||
|
||||
// some datasources simply tag the field as time, but don't convert to milli epochs
|
||||
// so we're stuck with doing the parsing here to avoid Moment slowness everywhere later
|
||||
// this mutates (once)
|
||||
for (let frame of series) {
|
||||
for (let field of frame.fields) {
|
||||
if (field.type === FieldType.time && typeof field.values.get(0) !== 'number') {
|
||||
field.values = convertFieldType(field, { destinationType: FieldType.time }).values;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (series.every((df) => df.meta?.type === DataFrameType.TimeSeriesLong)) {
|
||||
series = prepareTimeSeriesLong(series);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user