فهرست منبع

BarGauge: Round sizing to avoid float widths

LED cell width needs to be integers
Torkel Ödegaard 6 سال پیش
والد
کامیت
78ef1719e2
1فایلهای تغییر یافته به همراه3 افزوده شده و 2 حذف شده
  1. 3 2
      packages/grafana-ui/src/components/BarGauge/BarGauge.tsx

+ 3 - 2
packages/grafana-ui/src/components/BarGauge/BarGauge.tsx

@@ -136,8 +136,9 @@ export class BarGauge extends PureComponent<Props> {
     const valueRange = maxValue - minValue;
     const maxSize = isVert ? maxBarHeight : maxBarWidth;
     const cellSpacing = itemSpacing!;
-    const cellCount = maxSize / 20;
-    const cellSize = (maxSize - cellSpacing * cellCount) / cellCount;
+    const cellWidth = 12;
+    const cellCount = Math.floor(maxSize / cellWidth);
+    const cellSize = Math.floor((maxSize - cellSpacing * cellCount) / cellCount);
     const valueColor = getValueColor(this.props);
     const valueStyles = getValueStyles(value.text, valueColor, valueWidth, valueHeight);