瀏覽代碼

Gauge: Fix switching orientation issue when switching from BarGauge to Gauge (#17064)

Torkel Ödegaard 6 年之前
父節點
當前提交
68ad93f410
共有 2 個文件被更改,包括 4 次插入4 次删除
  1. 1 1
      packages/grafana-ui/src/components/Gauge/Gauge.tsx
  2. 3 3
      public/app/plugins/panel/gauge/GaugePanel.tsx

+ 1 - 1
packages/grafana-ui/src/components/Gauge/Gauge.tsx

@@ -76,7 +76,7 @@ export class Gauge extends PureComponent<Props> {
     );
     );
 
 
     const gaugeWidthReduceRatio = showThresholdLabels ? 1.5 : 1;
     const gaugeWidthReduceRatio = showThresholdLabels ? 1.5 : 1;
-    const gaugeWidth = Math.min(dimension / 5, 40) / gaugeWidthReduceRatio;
+    const gaugeWidth = Math.min(dimension / 5.5, 40) / gaugeWidthReduceRatio;
     const thresholdMarkersWidth = gaugeWidth / 5;
     const thresholdMarkersWidth = gaugeWidth / 5;
     const fontSize = Math.min(dimension / 5.5, 100) * (value.text !== null ? this.getFontScale(value.text.length) : 1);
     const fontSize = Math.min(dimension / 5.5, 100) * (value.text !== null ? this.getFontScale(value.text.length) : 1);
     const thresholdLabelFontSize = fontSize / 2.5;
     const thresholdLabelFontSize = fontSize / 2.5;

+ 3 - 3
public/app/plugins/panel/gauge/GaugePanel.tsx

@@ -5,7 +5,7 @@ import React, { PureComponent } from 'react';
 import { config } from 'app/core/config';
 import { config } from 'app/core/config';
 
 
 // Components
 // Components
-import { Gauge, FieldDisplay, getFieldDisplayValues } from '@grafana/ui';
+import { Gauge, FieldDisplay, getFieldDisplayValues, VizOrientation } from '@grafana/ui';
 
 
 // Types
 // Types
 import { GaugeOptions } from './types';
 import { GaugeOptions } from './types';
@@ -43,7 +43,7 @@ export class GaugePanel extends PureComponent<PanelProps<GaugeOptions>> {
   };
   };
 
 
   render() {
   render() {
-    const { height, width, options, data, renderCounter } = this.props;
+    const { height, width, data, renderCounter } = this.props;
     return (
     return (
       <VizRepeater
       <VizRepeater
         getValues={this.getValues}
         getValues={this.getValues}
@@ -52,7 +52,7 @@ export class GaugePanel extends PureComponent<PanelProps<GaugeOptions>> {
         height={height}
         height={height}
         source={data}
         source={data}
         renderCounter={renderCounter}
         renderCounter={renderCounter}
-        orientation={options.orientation}
+        orientation={VizOrientation.Auto}
       />
       />
     );
     );
   }
   }