Chore: More robust identification of time/value fields in makeSeriesForLogs (#23392)

* Chore: More robust identification of time/value fields in makeSeriesForLogs
This commit is contained in:
kay delaney 2020-04-08 09:07:12 +01:00 committed by GitHub
parent 2f7ba21593
commit a3b581a5f3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -136,30 +136,30 @@ export function makeSeriesForLogs(rows: LogRowModel[], intervalMs: number, timeZ
}
return seriesList.map((series, i) => {
series.datapoints.sort((a: number[], b: number[]) => {
return a[1] - b[1];
});
series.datapoints.sort((a: number[], b: number[]) => a[1] - b[1]);
// EEEP: converts GraphSeriesXY to DataFrame and back again!
const data = toDataFrame(series);
const points = getFlotPairs({
xField: data.fields[1],
yField: data.fields[0],
nullValueMode: NullValueMode.Null,
});
const fieldCache = new FieldCache(data);
const timeField = data.fields[1];
const timeField = fieldCache.getFirstFieldOfType(FieldType.time);
timeField.display = getDisplayProcessor({
field: timeField,
timeZone,
});
const valueField = data.fields[0];
const valueField = fieldCache.getFirstFieldOfType(FieldType.number);
valueField.config = {
...valueField.config,
color: series.color,
};
const points = getFlotPairs({
xField: timeField,
yField: valueField,
nullValueMode: NullValueMode.Null,
});
const graphSeries: GraphSeriesXY = {
color: series.color,
label: series.alias,