mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Stat: Add ability to remove default single-color background gradient (#64353)
* baldm0mma/feature/solidOption/ update cue and ts types * baldm0mma/feature/solidOption/ update data structures * baldm0mma/feature/solidOption/ vizrepeater investigation * baldm0mma/feature/solidOption/ add buildGradientBackground * baldm0mma/feature/solidOption/ remove conlogs from fieldDisplay.ts * baldm0mma/feature/solidOption/ rem destruct in fielddisplay.ts * baldm0mma/feature/solidOption/ rem conlogs from bivaluelayout.tsx * baldm0mma/feature/solidOption/ rem conlogs in visrepeater * baldm0mma/feature/solidOption/ rem conlogs from statpanel.tsx * baldm0mma/feature/solidOption/ add annotations in BigValue.tsx * baldm0mma/feature/solidOption/ update cue * baldm0mma/feature/solidOption/ remove unused anno * baldm0mma/feature/solidOption/ update with toggle conditinal * Update module.tsx update anno * baldm0mma/feature/solidOption/ update annos * baldm0mma/feature/solidOption/ undo change * baldm0mma/featurew/solidOption/ add anno for boolean toggle in stat module * baldm0mma/featurew/solidOption/ update anno in BigValue.tsx for hasGradient * baldm0mma/featurew/solidOption/ updart default logic in bigValueLayout.tsx
This commit is contained in:
parent
23e0f85ef9
commit
de901560d7
@ -27,6 +27,7 @@ It extends [SingleStatBaseOptions](#singlestatbaseoptions).
|
|||||||
| `graphMode` | string | **Yes** | TODO docs<br/>Possible values are: `none`, `line`, `area`. |
|
| `graphMode` | string | **Yes** | TODO docs<br/>Possible values are: `none`, `line`, `area`. |
|
||||||
| `justifyMode` | string | **Yes** | TODO docs<br/>Possible values are: `auto`, `center`. |
|
| `justifyMode` | string | **Yes** | TODO docs<br/>Possible values are: `auto`, `center`. |
|
||||||
| `textMode` | string | **Yes** | TODO docs<br/>Possible values are: `auto`, `value`, `value_and_name`, `name`, `none`. |
|
| `textMode` | string | **Yes** | TODO docs<br/>Possible values are: `auto`, `value`, `value_and_name`, `name`, `none`. |
|
||||||
|
| `hasGradient` | boolean | No | Default: `true`. |
|
||||||
| `orientation` | string | No | *(Inherited from [SingleStatBaseOptions](#singlestatbaseoptions))*<br/>TODO docs<br/>Possible values are: `auto`, `vertical`, `horizontal`. |
|
| `orientation` | string | No | *(Inherited from [SingleStatBaseOptions](#singlestatbaseoptions))*<br/>TODO docs<br/>Possible values are: `auto`, `vertical`, `horizontal`. |
|
||||||
| `reduceOptions` | [ReduceDataOptions](#reducedataoptions) | No | *(Inherited from [SingleStatBaseOptions](#singlestatbaseoptions))*<br/>TODO docs |
|
| `reduceOptions` | [ReduceDataOptions](#reducedataoptions) | No | *(Inherited from [SingleStatBaseOptions](#singlestatbaseoptions))*<br/>TODO docs |
|
||||||
| `text` | [VizTextDisplayOptions](#viztextdisplayoptions) | No | *(Inherited from [SingleStatBaseOptions](#singlestatbaseoptions))*<br/>TODO docs |
|
| `text` | [VizTextDisplayOptions](#viztextdisplayoptions) | No | *(Inherited from [SingleStatBaseOptions](#singlestatbaseoptions))*<br/>TODO docs |
|
||||||
|
@ -214,7 +214,7 @@ export function applyFieldOverrides(options: ApplyFieldOverrideOptions): DataFra
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// this is a significant optimization for streaming, where we currently re-process all values in the buffer on ech update
|
// this is a significant optimization for streaming, where we currently re-process all values in the buffer on each update
|
||||||
// via field.display(value). this can potentially be removed once we...
|
// via field.display(value). this can potentially be removed once we...
|
||||||
// 1. process data packets incrementally and/if cache the results in the streaming datafame (maybe by buffer index)
|
// 1. process data packets incrementally and/if cache the results in the streaming datafame (maybe by buffer index)
|
||||||
// 2. have the ability to selectively get display color or text (but not always both, which are each quite expensive)
|
// 2. have the ability to selectively get display color or text (but not always both, which are each quite expensive)
|
||||||
|
@ -53,6 +53,8 @@ export interface Props extends Themeable2 {
|
|||||||
className?: string;
|
className?: string;
|
||||||
/** Color mode for coloring the value or the background */
|
/** Color mode for coloring the value or the background */
|
||||||
colorMode: BigValueColorMode;
|
colorMode: BigValueColorMode;
|
||||||
|
/** Whether or not a horizontal gradient is applied to the panel background */
|
||||||
|
hasGradient?: boolean;
|
||||||
/** Show a graph behind/under the value */
|
/** Show a graph behind/under the value */
|
||||||
graphMode: BigValueGraphMode;
|
graphMode: BigValueGraphMode;
|
||||||
/** Auto justify value and text or center it */
|
/** Auto justify value and text or center it */
|
||||||
|
@ -117,7 +117,7 @@ export abstract class BigValueLayout {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getPanelStyles(): CSSProperties {
|
getPanelStyles(): CSSProperties {
|
||||||
const { width, height, theme, colorMode } = this.props;
|
const { width, height, theme, colorMode, hasGradient } = this.props;
|
||||||
|
|
||||||
const panelStyles: CSSProperties = {
|
const panelStyles: CSSProperties = {
|
||||||
width: `${width}px`,
|
width: `${width}px`,
|
||||||
@ -130,17 +130,23 @@ export abstract class BigValueLayout {
|
|||||||
|
|
||||||
const themeFactor = theme.isDark ? 1 : -0.7;
|
const themeFactor = theme.isDark ? 1 : -0.7;
|
||||||
|
|
||||||
|
function buildGradientBackground(valueColor: BigValueLayout['valueColor']) {
|
||||||
|
const bgColor2 = tinycolor(valueColor)
|
||||||
|
.darken(15 * themeFactor)
|
||||||
|
.spin(8)
|
||||||
|
.toRgbString();
|
||||||
|
const bgColor3 = tinycolor(valueColor)
|
||||||
|
.darken(5 * themeFactor)
|
||||||
|
.spin(-8)
|
||||||
|
.toRgbString();
|
||||||
|
|
||||||
|
return `linear-gradient(120deg, ${bgColor2}, ${bgColor3})`;
|
||||||
|
}
|
||||||
|
|
||||||
switch (colorMode) {
|
switch (colorMode) {
|
||||||
case BigValueColorMode.Background:
|
case BigValueColorMode.Background:
|
||||||
const bgColor2 = tinycolor(this.valueColor)
|
panelStyles.background =
|
||||||
.darken(15 * themeFactor)
|
hasGradient === false ? `none ${this.valueColor}` : buildGradientBackground(this.valueColor);
|
||||||
.spin(8)
|
|
||||||
.toRgbString();
|
|
||||||
const bgColor3 = tinycolor(this.valueColor)
|
|
||||||
.darken(5 * themeFactor)
|
|
||||||
.spin(-8)
|
|
||||||
.toRgbString();
|
|
||||||
panelStyles.background = `linear-gradient(120deg, ${bgColor2}, ${bgColor3})`;
|
|
||||||
break;
|
break;
|
||||||
case BigValueColorMode.Value:
|
case BigValueColorMode.Value:
|
||||||
panelStyles.background = `transparent`;
|
panelStyles.background = `transparent`;
|
||||||
|
@ -37,6 +37,7 @@ export class StatPanel extends PureComponent<PanelProps<PanelOptions>> {
|
|||||||
count={count}
|
count={count}
|
||||||
sparkline={sparkline}
|
sparkline={sparkline}
|
||||||
colorMode={options.colorMode}
|
colorMode={options.colorMode}
|
||||||
|
hasGradient={options.hasGradient}
|
||||||
graphMode={options.graphMode}
|
graphMode={options.graphMode}
|
||||||
justifyMode={options.justifyMode}
|
justifyMode={options.justifyMode}
|
||||||
textMode={this.getTextMode()}
|
textMode={this.getTextMode()}
|
||||||
|
@ -20,7 +20,7 @@ export const plugin = new PanelPlugin<PanelOptions>(StatPanel)
|
|||||||
builder.addSelect({
|
builder.addSelect({
|
||||||
path: 'textMode',
|
path: 'textMode',
|
||||||
name: 'Text mode',
|
name: 'Text mode',
|
||||||
description: 'Control if name and value is displayed or just name',
|
description: 'Control the display of the name and value',
|
||||||
category: mainCategory,
|
category: mainCategory,
|
||||||
settings: {
|
settings: {
|
||||||
options: [
|
options: [
|
||||||
@ -38,7 +38,7 @@ export const plugin = new PanelPlugin<PanelOptions>(StatPanel)
|
|||||||
.addRadio({
|
.addRadio({
|
||||||
path: 'colorMode',
|
path: 'colorMode',
|
||||||
name: 'Color mode',
|
name: 'Color mode',
|
||||||
defaultValue: BigValueColorMode.Value,
|
defaultValue: defaultPanelOptions.colorMode,
|
||||||
category: mainCategory,
|
category: mainCategory,
|
||||||
settings: {
|
settings: {
|
||||||
options: [
|
options: [
|
||||||
@ -48,6 +48,15 @@ export const plugin = new PanelPlugin<PanelOptions>(StatPanel)
|
|||||||
],
|
],
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
// Boolean toggle for removing the gradient panel background
|
||||||
|
.addBooleanSwitch({
|
||||||
|
path: 'hasGradient',
|
||||||
|
name: 'Background gradient',
|
||||||
|
defaultValue: defaultPanelOptions.hasGradient,
|
||||||
|
category: mainCategory,
|
||||||
|
// This toggle really only applies when the BigValueColorMode === `background`
|
||||||
|
showIf: (panelOptions) => panelOptions.colorMode === BigValueColorMode.Background,
|
||||||
|
})
|
||||||
.addRadio({
|
.addRadio({
|
||||||
path: 'graphMode',
|
path: 'graphMode',
|
||||||
name: 'Graph mode',
|
name: 'Graph mode',
|
||||||
|
@ -28,10 +28,11 @@ composableKinds: PanelCfg: {
|
|||||||
{
|
{
|
||||||
PanelOptions: {
|
PanelOptions: {
|
||||||
common.SingleStatBaseOptions
|
common.SingleStatBaseOptions
|
||||||
graphMode: common.BigValueGraphMode | *"area"
|
graphMode: common.BigValueGraphMode | *"area"
|
||||||
colorMode: common.BigValueColorMode | *"value"
|
colorMode: common.BigValueColorMode | *"value"
|
||||||
justifyMode: common.BigValueJustifyMode | *"auto"
|
hasGradient?: bool | *true
|
||||||
textMode: common.BigValueTextMode | *"auto"
|
justifyMode: common.BigValueJustifyMode | *"auto"
|
||||||
|
textMode: common.BigValueTextMode | *"auto"
|
||||||
} @cuetsy(kind="interface")
|
} @cuetsy(kind="interface")
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
@ -15,6 +15,7 @@ export const PanelCfgModelVersion = Object.freeze([0, 0]);
|
|||||||
export interface PanelOptions extends common.SingleStatBaseOptions {
|
export interface PanelOptions extends common.SingleStatBaseOptions {
|
||||||
colorMode: common.BigValueColorMode;
|
colorMode: common.BigValueColorMode;
|
||||||
graphMode: common.BigValueGraphMode;
|
graphMode: common.BigValueGraphMode;
|
||||||
|
hasGradient?: boolean;
|
||||||
justifyMode: common.BigValueJustifyMode;
|
justifyMode: common.BigValueJustifyMode;
|
||||||
textMode: common.BigValueTextMode;
|
textMode: common.BigValueTextMode;
|
||||||
}
|
}
|
||||||
@ -22,6 +23,7 @@ export interface PanelOptions extends common.SingleStatBaseOptions {
|
|||||||
export const defaultPanelOptions: Partial<PanelOptions> = {
|
export const defaultPanelOptions: Partial<PanelOptions> = {
|
||||||
colorMode: common.BigValueColorMode.Value,
|
colorMode: common.BigValueColorMode.Value,
|
||||||
graphMode: common.BigValueGraphMode.Area,
|
graphMode: common.BigValueGraphMode.Area,
|
||||||
|
hasGradient: true,
|
||||||
justifyMode: common.BigValueJustifyMode.Auto,
|
justifyMode: common.BigValueJustifyMode.Auto,
|
||||||
textMode: common.BigValueTextMode.Auto,
|
textMode: common.BigValueTextMode.Auto,
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user