grafana/public/app/plugins/panel/timeseries/StackingEditor.tsx
Dominik Prokop 0cc620aea7
GraphNG: stacking (#30749)
* First iteration

* Dev dash

* Re-use StackingMode type

* Fix ts and api issues

* Stacking work resurected

* Fix overrides

* Correct values in tooltip and updated test dashboard

* Update dev dashboard

* Apply correct bands for stacking

* Merge fix

* Update snapshot

* Revert go.sum

* Handle null values correctyl and make filleBelowTo and stacking mutual exclusive

* Snapshots update

* Graph->Time series stacking migration

* Review comments

* Indicate overrides in StandardEditorContext

* Change stacking UI editor, migrate stacking to object option

* Small refactor, fix for hiding series and dev dashboard
2021-04-15 13:00:01 +02:00

52 lines
1.2 KiB
TypeScript

import React from 'react';
import { FieldOverrideEditorProps } from '@grafana/data';
import {
HorizontalGroup,
IconButton,
Input,
RadioButtonGroup,
StackingConfig,
StackingMode,
Tooltip,
} from '@grafana/ui';
export const StackingEditor: React.FC<FieldOverrideEditorProps<StackingConfig, any>> = ({
value,
context,
onChange,
item,
}) => {
return (
<HorizontalGroup>
<RadioButtonGroup
value={value?.mode || StackingMode.None}
options={item.settings.options}
onChange={(v) => {
onChange({
...value,
mode: v,
});
}}
/>
{context.isOverride && value?.mode && value?.mode !== StackingMode.None && (
<Input
type="text"
placeholder="Group"
suffix={
<Tooltip content="Name of the stacking group" placement="top">
<IconButton name="question-circle" />
</Tooltip>
}
defaultValue={value?.group}
onChange={(v) => {
onChange({
...value,
group: v.currentTarget.value.trim(),
});
}}
/>
)}
</HorizontalGroup>
);
};