Skip to content

Function: bubbleSizeref() ​

ts
function bubbleSizeref(sizes, maxPx, options?): number;

The marker.sizeref that draws the largest of sizes as a bubble maxPx CSS px across, so data of any magnitude maps to a readable range of marker sizes. For sizemode: 'area' (the usual bubble setting) this is Plotly's documented 2 · max(size) / maxPx²; for 'diameter' it is max(size) / maxPx.

Non-numeric, non-finite and non-positive sizes are ignored; with no positive size (or a non-positive maxPx) the result is 1, Plotly's default.

Parameters ​

ParameterType
sizesArrayLike<unknown>
maxPxnumber
optionsBubbleSizerefOptions

Returns ​

number

Example ​

ts
const size = [12, 40, 7, 95];
createChart(el, {
  data: [
    { x, y, mode: 'markers', marker: { size, sizemode: 'area', sizeref: bubbleSizeref(size, 60) } },
  ],
});

Released under the MIT License.