mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Transformations: Use the display name of the original y field for the predicted field of the regression analysis transformation. (#81332)
Fix name of regression transformation field
This commit is contained in:
parent
d8d9121b6d
commit
9a4534a17c
@ -9,6 +9,7 @@ import {
|
||||
FieldType,
|
||||
SynchronousDataTransformerInfo,
|
||||
fieldMatchers,
|
||||
getFieldDisplayName,
|
||||
} from '@grafana/data';
|
||||
|
||||
export enum ModelType {
|
||||
@ -42,6 +43,7 @@ export const RegressionTransformer: SynchronousDataTransformerInfo<RegressionTra
|
||||
|
||||
let xField;
|
||||
let yField;
|
||||
let predictFromFrame;
|
||||
for (const frame of frames) {
|
||||
const fy = frame.fields.find((f) => matchesY(f, frame, frames));
|
||||
if (fy) {
|
||||
@ -49,6 +51,7 @@ export const RegressionTransformer: SynchronousDataTransformerInfo<RegressionTra
|
||||
const fx = frame.fields.find((f) => matchesX(f, frame, frames));
|
||||
if (fx) {
|
||||
xField = fx;
|
||||
predictFromFrame = frame;
|
||||
break;
|
||||
} else {
|
||||
throw 'X and Y fields must be part of the same frame';
|
||||
@ -108,7 +111,7 @@ export const RegressionTransformer: SynchronousDataTransformerInfo<RegressionTra
|
||||
fields: [
|
||||
{ name: xField.name, type: xField.type, values: predictionPoints, config: {} },
|
||||
{
|
||||
name: `${yField.name} predicted`,
|
||||
name: `${getFieldDisplayName(yField, predictFromFrame, frames)} predicted`,
|
||||
type: yField.type,
|
||||
values: predictionPoints.map((x) => result.predict(x - normalizationSubtrahend)),
|
||||
config: {},
|
||||
|
Loading…
Reference in New Issue
Block a user