mirror of
https://github.com/grafana/grafana.git
synced 2024-11-23 09:26:43 -06:00
Phlare: Set enum field type to enum instead of integer (#72078)
Co-authored-by: Leon Sorokin <leeoniya@gmail.com>
This commit is contained in:
parent
9a6a739003
commit
8c86a46440
@ -318,7 +318,7 @@ type EnumField struct {
|
||||
|
||||
func NewEnumField(name string, labels data.Labels) *EnumField {
|
||||
return &EnumField{
|
||||
field: data.NewField(name, labels, []int64{}),
|
||||
field: data.NewField(name, labels, []data.EnumItemIndex{}),
|
||||
valuesMap: make(map[string]int64),
|
||||
}
|
||||
}
|
||||
@ -328,7 +328,7 @@ func (e *EnumField) Append(value string) {
|
||||
e.field.Append(valueIndex)
|
||||
} else {
|
||||
e.valuesMap[value] = e.counter
|
||||
e.field.Append(e.counter)
|
||||
e.field.Append(data.EnumItemIndex(e.counter))
|
||||
e.counter++
|
||||
}
|
||||
}
|
||||
|
@ -135,7 +135,7 @@ func Test_profileToDataFrame(t *testing.T) {
|
||||
require.Equal(t, data.NewField("value", nil, []int64{20, 10, 5}).SetConfig(&data.FieldConfig{Unit: "short"}), frame.Fields[1])
|
||||
require.Equal(t, data.NewField("self", nil, []int64{1, 3, 5}).SetConfig(&data.FieldConfig{Unit: "short"}), frame.Fields[2])
|
||||
require.Equal(t, "label", frame.Fields[3].Name)
|
||||
require.Equal(t, []int64{0, 1, 2}, fieldValues[int64](frame.Fields[3]))
|
||||
require.Equal(t, []data.EnumItemIndex{0, 1, 2}, fieldValues[data.EnumItemIndex](frame.Fields[3]))
|
||||
require.Equal(t, []string{"func1", "func2", "func3"}, frame.Fields[3].Config.TypeConfig.Enum.Text)
|
||||
}
|
||||
|
||||
@ -214,7 +214,7 @@ func Test_treeToNestedDataFrame(t *testing.T) {
|
||||
data.NewField("level", nil, []int64{0, 1, 1, 2}),
|
||||
data.NewField("value", nil, []int64{100, 40, 30, 15}).SetConfig(&data.FieldConfig{Unit: "short"}),
|
||||
data.NewField("self", nil, []int64{1, 2, 3, 4}).SetConfig(&data.FieldConfig{Unit: "short"}),
|
||||
data.NewField("label", nil, []int64{0, 1, 2, 3}).SetConfig(labelConfig),
|
||||
data.NewField("label", nil, []data.EnumItemIndex{0, 1, 2, 3}).SetConfig(labelConfig),
|
||||
}, frame.Fields)
|
||||
})
|
||||
|
||||
|
@ -1,12 +1,4 @@
|
||||
import {
|
||||
createTheme,
|
||||
DataFrame,
|
||||
DisplayProcessor,
|
||||
Field,
|
||||
FieldType,
|
||||
getDisplayProcessor,
|
||||
GrafanaTheme2,
|
||||
} from '@grafana/data';
|
||||
import { createTheme, DataFrame, DisplayProcessor, Field, getDisplayProcessor, GrafanaTheme2 } from '@grafana/data';
|
||||
|
||||
import { SampleUnit } from '../types';
|
||||
|
||||
@ -107,8 +99,6 @@ export class FlameGraphDataContainer {
|
||||
// both a backward compatibility but also to allow using a simple dataFrame without enum config. This would allow
|
||||
// users to use this panel with correct query from data sources that do not return profiles natively.
|
||||
if (enumConfig) {
|
||||
// TODO: Fix this from backend to set field type to enum correctly
|
||||
this.labelField.type = FieldType.enum;
|
||||
this.labelDisplayProcessor = getDisplayProcessor({ field: this.labelField, theme });
|
||||
this.uniqueLabels = enumConfig.text || [];
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user