Skip to content

Commit

Permalink
zero option
Browse files Browse the repository at this point in the history
  • Loading branch information
sfranzis committed Nov 10, 2022
1 parent 5204857 commit b31bbdb
Show file tree
Hide file tree
Showing 9 changed files with 5,540 additions and 11,821 deletions.
5 changes: 4 additions & 1 deletion packages/grafana-ui/src/components/Gauge/Gauge.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export interface Props extends Themeable {
field: FieldConfig;
showThresholdMarkers: boolean;
showThresholdLabels: boolean;
neutral: Number;
width: number;
value: DisplayValue;
text?: VizTextDisplayOptions;
Expand Down Expand Up @@ -50,14 +51,15 @@ export class Gauge extends PureComponent<Props> {
}

draw() {
const { field, showThresholdLabels, showThresholdMarkers, width, height, theme, value } = this.props;
const { field, showThresholdLabels, showThresholdMarkers, width, height, theme, value, neutral } = this.props;

const autoProps = calculateGaugeAutoProps(width, height, value.title);
const dimension = Math.min(width, autoProps.gaugeHeight);
const backgroundColor = theme.colors.bg2;
const gaugeWidthReduceRatio = showThresholdLabels ? 1.5 : 1;
const gaugeWidth = Math.min(dimension / 5.5, 40) / gaugeWidthReduceRatio;
const thresholdMarkersWidth = gaugeWidth / 5;
const neutralValue = neutral;
const text = formattedValueToString(value);
// This not 100% accurate as I am unsure of flot's calculations here
const valueWidthBase = Math.min(width, dimension * 1.3) * 0.9;
Expand Down Expand Up @@ -96,6 +98,7 @@ export class Gauge extends PureComponent<Props> {
gauge: {
min,
max,
neutralValue,
background: { color: backgroundColor },
border: { color: null },
shadow: { show: false },
Expand Down

0 comments on commit b31bbdb

Please sign in to comment.