Explore: Replaces TimeSeries with GraphSeriesXY (#18475)

* Wip: Compiles and runs

* WIP: Logs Graph partially working

* Refactor: Adds GraphSeriesToggler

* Refactor: Adds tickDecimals to YAxis

* Refactor: Adds TimeZone and PlotSelection to Graph

* Refactor: Makes the graphResult work in Explore

* Refactor: Adds ExploreGraphPanel that is used by Logs and Explore

* Fix: Fixes strange behaviour with ExploreMode not beeing changed

* Fix: Adds onSelectionChanged to GraphWithLegend

* Refactor: Cleans up unused comments

* ExploreGraph: Disable colorpicker
This commit is contained in:
Hugo Häggmark
2019-08-13 07:32:43 +02:00
committed by GitHub
parent 8fd153edb7
commit 4b3440325e
30 changed files with 550 additions and 997 deletions

View File

@@ -1,5 +1,11 @@
import { DisplayValue } from './displayValue';
export interface YAxis {
index: number;
min?: number;
tickDecimals?: number;
}
export type GraphSeriesValue = number | null;
/** View model projection of a series */
@@ -9,7 +15,7 @@ export interface GraphSeriesXY {
data: GraphSeriesValue[][]; // [x,y][]
info?: DisplayValue[]; // Legend info
isVisible: boolean;
yAxis: number;
yAxis: YAxis;
}
export interface CreatePlotOverlay {

View File

@@ -1,4 +1,5 @@
import { Labels, TimeSeries } from './data';
import { Labels } from './data';
import { GraphSeriesXY } from './graph';
/**
* Mapping of log level abbreviation to canonical log level.
@@ -54,7 +55,7 @@ export interface LogsModel {
hasUniqueLabels: boolean;
meta?: LogsMetaItem[];
rows: LogRowModel[];
series?: TimeSeries[];
series?: GraphSeriesXY[];
}
export interface LogSearchMatch {

View File

@@ -4,7 +4,7 @@ import isString from 'lodash/isString';
import isBoolean from 'lodash/isBoolean';
// Types
import { DataFrame, Field, TimeSeries, FieldType, TableData, Column } from '../types/index';
import { DataFrame, Field, TimeSeries, FieldType, TableData, Column, GraphSeriesXY } from '../types/index';
import { isDateTime } from './moment_wrapper';
function convertTableToDataFrame(table: TableData): DataFrame {
@@ -44,6 +44,23 @@ function convertTimeSeriesToDataFrame(timeSeries: TimeSeries): DataFrame {
};
}
function convertGraphSeriesToDataFrame(graphSeries: GraphSeriesXY): DataFrame {
return {
name: graphSeries.label,
fields: [
{
name: graphSeries.label || 'Value',
},
{
name: 'Time',
type: FieldType.time,
unit: 'dateTimeAsIso',
},
],
rows: graphSeries.data,
};
}
// PapaParse Dynamic Typing regex:
// https://github.com/mholt/PapaParse/blob/master/papaparse.js#L998
const NUMBER = /^\s*-?(\d*\.?\d+|\d+\.?\d*)(e[-+]?\d+)?\s*$/i;
@@ -145,6 +162,9 @@ export const toDataFrame = (data: any): DataFrame => {
if (data.hasOwnProperty('datapoints')) {
return convertTimeSeriesToDataFrame(data);
}
if (data.hasOwnProperty('data')) {
return convertGraphSeriesToDataFrame(data);
}
if (data.hasOwnProperty('columns')) {
return convertTableToDataFrame(data);
}