Skip to content

The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:

specify gauge label sizes in px (#67386)

Nick Fitzpatrick05d04cf64b7b
diff --git a/frontend/src/metabase/visualizations/visualizations/Gauge/Gauge.jsx b/frontend/src/metabase/visualizations/visualizations/Gauge/Gauge.jsx
index c62d98eb440..5dde3cb4163 100644
--- a/frontend/src/metabase/visualizations/visualizations/Gauge/Gauge.jsx
+++ b/frontend/src/metabase/visualizations/visualizations/Gauge/Gauge.jsx
@@ -40,8 +40,10 @@ const getCenterLabelColor = () => color("text-dark");
const getArrowFillColor = () => color("text-medium-opaque");
const getArrowStrokeColor = () => color("bg-white");
+// in px, because scaling was not working well with PDF Exports (metabase#65322)
+const FONT_SIZE_SEGMENT_LABEL = 4;
+
// in ems, but within the scaled 100px SVG element
-const FONT_SIZE_SEGMENT_LABEL = 0.28;
const FONT_SIZE_CENTER_LABEL_MIN = 0.5;
const FONT_SIZE_CENTER_LABEL_MAX = 0.7;
@@ -436,11 +438,11 @@ const GaugeSegmentLabel = ({ position: [x, y], style = {}, children }) => (
y={y}
style={{
fill: "var(--mb-color-text-medium)",
- fontSize: `${FONT_SIZE_SEGMENT_LABEL}em`,
+ fontSize: `${FONT_SIZE_SEGMENT_LABEL}px`,
textAnchor: Math.abs(x) < 5 ? "middle" : x > 0 ? "start" : "end",
// shift text in the lower half down a bit
transform:
- y > 0 ? `translate(0,${FONT_SIZE_SEGMENT_LABEL}em)` : undefined,
+ y > 0 ? `translate(0,${FONT_SIZE_SEGMENT_LABEL / 2}px)` : undefined,
...style,
}}
>