TimeSeries: Replace fieldName with fieldIndex (#19030)

pull/19031/head
Dominik Prokop 6 years ago committed by GitHub
parent c66a23ea31
commit 0607189ed5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 9
      public/app/core/time_series2.ts
  2. 9
      public/app/plugins/panel/graph/data_processor.ts
  3. 12
      public/app/plugins/panel/graph/specs/__snapshots__/data_processor.test.ts.snap

@ -77,11 +77,8 @@ export default class TimeSeries {
id: string; id: string;
// Represents index of original data frame in the quey response // Represents index of original data frame in the quey response
dataFrameIndex: number; dataFrameIndex: number;
/** // Represents index of field in the data frame
* Name of the field the time series was created from fieldIndex: number;
* Used in graph panel to retrieve value from the original data frame
*/
fieldName: string;
label: string; label: string;
alias: string; alias: string;
aliasEscaped: string; aliasEscaped: string;
@ -122,8 +119,8 @@ export default class TimeSeries {
this.stats = {}; this.stats = {};
this.legend = true; this.legend = true;
this.unit = opts.unit; this.unit = opts.unit;
this.fieldName = opts.fieldName;
this.dataFrameIndex = opts.dataFrameIndex; this.dataFrameIndex = opts.dataFrameIndex;
this.fieldIndex = opts.fieldIndex;
this.hasMsResolution = this.isMsResolutionNeeded(); this.hasMsResolution = this.isMsResolutionNeeded();
} }

@ -28,7 +28,8 @@ export class DataProcessor {
} }
const seriesName = series.name ? series.name : series.refId; const seriesName = series.name ? series.name : series.refId;
for (const field of series.fields) { for (let j = 0; j < series.fields.length; j++) {
const field = series.fields[j];
if (field.type !== FieldType.number) { if (field.type !== FieldType.number) {
continue; continue;
} }
@ -43,8 +44,7 @@ export class DataProcessor {
for (let r = 0; r < series.length; r++) { for (let r = 0; r < series.length; r++) {
datapoints.push([field.values.get(r), timeField.values.get(r)]); datapoints.push([field.values.get(r), timeField.values.get(r)]);
} }
list.push(this.toTimeSeries(field, name, i, j, datapoints, list.length, range));
list.push(this.toTimeSeries(field, name, i, datapoints, list.length, range));
} }
} }
@ -65,6 +65,7 @@ export class DataProcessor {
field: Field, field: Field,
alias: string, alias: string,
dataFrameIndex: number, dataFrameIndex: number,
fieldIndex: number,
datapoints: any[][], datapoints: any[][],
index: number, index: number,
range?: TimeRange range?: TimeRange
@ -77,8 +78,8 @@ export class DataProcessor {
alias: alias, alias: alias,
color: getColorFromHexRgbOrName(color, config.theme.type), color: getColorFromHexRgbOrName(color, config.theme.type),
unit: field.config ? field.config.unit : undefined, unit: field.config ? field.config.unit : undefined,
fieldName: field.name,
dataFrameIndex, dataFrameIndex,
fieldIndex,
}); });
if (datapoints && datapoints.length > 0 && range) { if (datapoints && datapoints.length > 0 && range) {

@ -24,7 +24,7 @@ Array [
1003, 1003,
], ],
], ],
"fieldName": "Value", "fieldIndex": 0,
"hasMsResolution": false, "hasMsResolution": false,
"id": "Value", "id": "Value",
"label": "Value", "label": "Value",
@ -55,7 +55,7 @@ Array [
1003, 1003,
], ],
], ],
"fieldName": "v1", "fieldIndex": 1,
"hasMsResolution": false, "hasMsResolution": false,
"id": "table_data v1", "id": "table_data v1",
"label": "table_data v1", "label": "table_data v1",
@ -86,7 +86,7 @@ Array [
1003, 1003,
], ],
], ],
"fieldName": "v2", "fieldIndex": 2,
"hasMsResolution": false, "hasMsResolution": false,
"id": "table_data v2", "id": "table_data v2",
"label": "table_data v2", "label": "table_data v2",
@ -117,7 +117,7 @@ Array [
1003, 1003,
], ],
], ],
"fieldName": "v1", "fieldIndex": 0,
"hasMsResolution": false, "hasMsResolution": false,
"id": "series v1", "id": "series v1",
"label": "series v1", "label": "series v1",
@ -148,7 +148,7 @@ Array [
1003, 1003,
], ],
], ],
"fieldName": "v2", "fieldIndex": 1,
"hasMsResolution": false, "hasMsResolution": false,
"id": "series v2", "id": "series v2",
"label": "series v2", "label": "series v2",
@ -232,7 +232,7 @@ Array [
1003, 1003,
], ],
], ],
"fieldName": "Value", "fieldIndex": 0,
"hasMsResolution": false, "hasMsResolution": false,
"id": "Value", "id": "Value",
"label": "Value", "label": "Value",

Loading…
Cancel
Save