add negative y config
This commit is contained in:
1 parent
8b6a07a313
commit
fc413c9c7f
5 files changed
+35
-1
No files matched your search
@@ -65,6 +65,8 @@ export const valueMappingsOverrideProcessor = (
|
||||
export interface SelectFieldConfigSettings<T> {
|
||||
allowCustomValue?: boolean;
|
||||
|
||||
isClearable?: boolean;
|
||||
|
||||
/** The default options */
|
||||
options: Array<SelectableValue<T>>;
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ LineInterpolation: "linear" | "smooth" | "stepBefore" | "stepAfter" @cue
|
||||
ScaleDistribution: "linear" | "log" | "ordinal" @cuetsy(kind="enum")
|
||||
GraphGradientMode: "none" | "opacity" | "hue" | "scheme" @cuetsy(kind="enum")
|
||||
StackingMode: "none" | "normal" | "percent" @cuetsy(kind="enum")
|
||||
GraphTransform: "constant" | "negative-Y" @cuetsy(kind="enum")
|
||||
BarAlignment: -1 | 0 | 1 @cuetsy(kind="enum",memberNames="Before|Center|After")
|
||||
ScaleOrientation: 0 | 1 @cuetsy(kind="enum",memberNames="Horizontal|Vertical")
|
||||
ScaleDirection: 1 | 1 | -1 | -1 @cuetsy(kind="enum",memberNames="Up|Right|Down|Left")
|
||||
@@ -84,4 +85,5 @@ GraphFieldConfig: {
|
||||
drawStyle?: GraphDrawStyle
|
||||
gradientMode?: GraphGradientMode
|
||||
thresholdsStyle?: GraphThresholdsStyleConfig
|
||||
transform?: GraphTransform
|
||||
} @cuetsy(kind="interface")
|
||||
@@ -24,6 +24,11 @@ export enum GraphDrawStyle {
|
||||
Points = 'points',
|
||||
}
|
||||
|
||||
export enum GraphTransform {
|
||||
Constant = 'constant',
|
||||
NegativeY = 'negative-Y',
|
||||
}
|
||||
|
||||
export enum LineInterpolation {
|
||||
Linear = 'linear',
|
||||
Smooth = 'smooth',
|
||||
@@ -250,6 +255,7 @@ export interface GraphFieldConfig
|
||||
drawStyle?: GraphDrawStyle;
|
||||
gradientMode?: GraphGradientMode;
|
||||
thresholdsStyle?: GraphThresholdsStyleConfig;
|
||||
transform?: GraphTransform;
|
||||
}
|
||||
|
||||
export interface VizLegendOptions {
|
||||
|
||||
@@ -67,7 +67,8 @@ export class SelectValueEditor<T> extends React.PureComponent<Props<T>, State<T>
|
||||
value={current}
|
||||
defaultValue={value}
|
||||
allowCustomValue={settings?.allowCustomValue}
|
||||
onChange={(e) => onChange(e.value)}
|
||||
isClearable={settings?.isClearable}
|
||||
onChange={(e) => onChange(e?.value)}
|
||||
options={options}
|
||||
/>
|
||||
);
|
||||
|
||||
@@ -16,6 +16,7 @@ import {
|
||||
VisibilityMode,
|
||||
StackingMode,
|
||||
GraphTresholdsStyleMode,
|
||||
GraphTransform,
|
||||
} from '@grafana/schema';
|
||||
|
||||
import { graphFieldOptions, commonOptionsBuilder } from '@grafana/ui';
|
||||
@@ -181,6 +182,28 @@ export function getGraphFieldConfig(cfg: GraphFieldConfig): SetFieldConfigOption
|
||||
});
|
||||
|
||||
commonOptionsBuilder.addStackingConfig(builder, cfg.stacking, categoryStyles);
|
||||
|
||||
builder.addSelect({
|
||||
category: categoryStyles,
|
||||
name: 'Transform',
|
||||
path: 'transform',
|
||||
settings: {
|
||||
options: [
|
||||
{
|
||||
label: 'Constant',
|
||||
value: GraphTransform.Constant,
|
||||
description: 'The first value will be shown as a constant line',
|
||||
},
|
||||
{
|
||||
label: 'Negative Y',
|
||||
value: GraphTransform.NegativeY,
|
||||
description: 'Flip the results to negative values on the y axis',
|
||||
},
|
||||
],
|
||||
isClearable: true,
|
||||
},
|
||||
});
|
||||
|
||||
commonOptionsBuilder.addAxisConfig(builder, cfg);
|
||||
commonOptionsBuilder.addHideFrom(builder);
|
||||
|
||||
|
||||
Reference in new issue
Block a user