Skip to content

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

Fix math to calculate scatter bubble diameter (#63104)

eliotmetabase7b4ed715aec0
diff --git a/.loki/reference/chrome_laptop_Components_Inputs_DateTimePicker_Default.png b/.loki/reference/chrome_laptop_Components_Inputs_DateTimePicker_Default.png
deleted file mode 100644
index c94308360ed..00000000000
Binary files a/.loki/reference/chrome_laptop_Components_Inputs_DateTimePicker_Default.png and /dev/null differ
diff --git a/.loki/reference/chrome_laptop_Components_Inputs_DateTimePicker_Value_Format.png b/.loki/reference/chrome_laptop_Components_Inputs_DateTimePicker_Value_Format.png
deleted file mode 100644
index 1d72848a709..00000000000
Binary files a/.loki/reference/chrome_laptop_Components_Inputs_DateTimePicker_Value_Format.png and /dev/null differ
diff --git a/.loki/reference/chrome_laptop_Components_Inputs_DateTimePicker_With_Seconds.png b/.loki/reference/chrome_laptop_Components_Inputs_DateTimePicker_With_Seconds.png
deleted file mode 100644
index a70e5a41c48..00000000000
Binary files a/.loki/reference/chrome_laptop_Components_Inputs_DateTimePicker_With_Seconds.png and /dev/null differ
diff --git a/.loki/reference/chrome_laptop_Viz_Static_Viz_ScatterPlot_Bubble_Size.png b/.loki/reference/chrome_laptop_Viz_Static_Viz_ScatterPlot_Bubble_Size.png
index 45051027978..417047fbe03 100644
Binary files a/.loki/reference/chrome_laptop_Viz_Static_Viz_ScatterPlot_Bubble_Size.png and b/.loki/reference/chrome_laptop_Viz_Static_Viz_ScatterPlot_Bubble_Size.png differ
diff --git a/.loki/reference/chrome_laptop_Viz_Static_Viz_ScatterPlot_Multi_Dimension_Breakout_Bubble_Size.png b/.loki/reference/chrome_laptop_Viz_Static_Viz_ScatterPlot_Multi_Dimension_Breakout_Bubble_Size.png
index d9ac0720b29..3c78671dfad 100644
Binary files a/.loki/reference/chrome_laptop_Viz_Static_Viz_ScatterPlot_Multi_Dimension_Breakout_Bubble_Size.png and b/.loki/reference/chrome_laptop_Viz_Static_Viz_ScatterPlot_Multi_Dimension_Breakout_Bubble_Size.png differ
diff --git a/.loki/reference/chrome_laptop_Viz_Static_Viz_ScatterPlot_Pin_To_Zero.png b/.loki/reference/chrome_laptop_Viz_Static_Viz_ScatterPlot_Pin_To_Zero.png
index b5085fc2ae8..ff3403c6296 100644
Binary files a/.loki/reference/chrome_laptop_Viz_Static_Viz_ScatterPlot_Pin_To_Zero.png and b/.loki/reference/chrome_laptop_Viz_Static_Viz_ScatterPlot_Pin_To_Zero.png differ
diff --git a/frontend/src/metabase/visualizations/echarts/cartesian/scatter/option/series.ts b/frontend/src/metabase/visualizations/echarts/cartesian/scatter/option/series.ts
index 174b76139c6..e3462310572 100644
--- a/frontend/src/metabase/visualizations/echarts/cartesian/scatter/option/series.ts
+++ b/frontend/src/metabase/visualizations/echarts/cartesian/scatter/option/series.ts
@@ -38,8 +38,8 @@ function getBubbleDiameterScale(
// D3 will take a value from the domain (bubble size column) and normalize it (`t` is between 0,1).
// Then we plug the normalized value `t` into the `areaScale` to get the corrseponding area for that diameter.
// We then take this area and convert it back to a diameter value
- // if area = π × (diameter ÷ 2)², then diameter = (2 × √area) ÷ π
- .interpolate(() => (t) => (2 * Math.sqrt(areaScale(t))) / Math.PI)
+ // if area = π × (diameter ÷ 2)², then diameter = 2 × √(area ÷ π)
+ .interpolate(() => (t) => 2 * Math.sqrt(areaScale(t) / Math.PI))
// Finally, D3 linearly maps that value into our defined min/max range.
.range([MIN_BUBBLE_DIAMETER, MAX_BUBBLE_DIAMETER]);