@vizabi/bubblechart 5.5.3 → 5.5.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- // https://github.com/vizabi/bubblechart#readme v5.5.3 build 1768916445428 Copyright 2026 Gapminder Foundation and contributors
1
+ // https://github.com/vizabi/bubblechart#readme v5.5.5 build 1791750840591 Copyright 2026 Gapminder Foundation and contributors
2
2
  (function (global, factory) {
3
3
  typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@vizabi/shared-components'), require('d3'), require('mobx'), require('@deck.gl/core'), require('@deck.gl/layers')) :
4
4
  typeof define === 'function' && define.amd ? define(['exports', '@vizabi/shared-components', 'd3', 'mobx', '@deck.gl/core', '@deck.gl/layers'], factory) :
@@ -1423,8 +1423,10 @@ in float instanceSizes;
1423
1423
  in float instanceAngles;
1424
1424
  in vec2 instancePixelOffsets;
1425
1425
  in float instanceLineWidths;
1426
+ in float instanceGlowWidths;
1426
1427
  in vec4 instanceFillColors;
1427
1428
  in vec4 instanceLineColors;
1429
+ in vec4 instanceGlowColors;
1428
1430
  in vec3 instancePickingColors;
1429
1431
  in float instanceDragged;
1430
1432
 
@@ -1437,9 +1439,11 @@ uniform vec4 padding;
1437
1439
  uniform int sizeUnits;
1438
1440
  uniform float edgeMaxCoord;
1439
1441
 
1442
+ out vec4 vGlowColor;
1440
1443
  out vec4 vFillColor;
1441
1444
  out vec4 vLineColor;
1442
1445
  out float vLineWidth;
1446
+ out float vGlowWidth;
1443
1447
  out vec2 uv;
1444
1448
  out vec2 dimensions;
1445
1449
 
@@ -1457,6 +1461,8 @@ void main(void) {
1457
1461
  geometry.pickingColor = instancePickingColors;
1458
1462
  uv = positions;
1459
1463
  vLineWidth = instanceLineWidths;
1464
+ vGlowWidth = instanceGlowWidths;
1465
+ vec4 glowPadding = padding + vec4(instanceGlowWidths);
1460
1466
 
1461
1467
  // convert size in meters to pixels, then scaled and clamp
1462
1468
 
@@ -1466,9 +1472,9 @@ void main(void) {
1466
1472
  sizeMinPixels, sizeMaxPixels
1467
1473
  );
1468
1474
 
1469
- dimensions = instanceRects.zw * sizePixels + padding.xy + padding.zw;
1475
+ dimensions = instanceRects.zw * sizePixels + glowPadding.xy + glowPadding.zw;
1470
1476
 
1471
- vec2 pixelOffset = (positions * instanceRects.zw + instanceRects.xy) * sizePixels + mix(-padding.xy, padding.zw, positions);
1477
+ vec2 pixelOffset = (positions * instanceRects.zw + instanceRects.xy) * sizePixels + mix(-glowPadding.xy, glowPadding.zw, positions);
1472
1478
  pixelOffset = rotate_by_angle(pixelOffset, instanceAngles);
1473
1479
  pixelOffset += instancePixelOffsets;
1474
1480
  pixelOffset.y *= -1.0;
@@ -1481,6 +1487,7 @@ void main(void) {
1481
1487
  gl_Position.xy += project_pixel_size_to_clipspace(offset.xy);
1482
1488
 
1483
1489
  vec2 clip_dimensions = project_pixel_size_to_clipspace(dimensions);
1490
+ vec2 clip_glow = project_pixel_size_to_clipspace(vec2(vGlowWidth));
1484
1491
 
1485
1492
  //default pos switch on edge
1486
1493
  if (instanceDragged < 0.5) {
@@ -1490,8 +1497,8 @@ void main(void) {
1490
1497
  }
1491
1498
 
1492
1499
  //edge check
1493
- vec2 a = clamp(gl_Position.xy, vec2(-edgeMaxCoord), vec2(edgeMaxCoord) - clip_dimensions);
1494
- vec2 b = clamp(gl_Position.xy, clip_dimensions - edgeMaxCoord, vec2(edgeMaxCoord));
1500
+ vec2 a = clamp(gl_Position.xy, vec2(-edgeMaxCoord) - clip_glow, vec2(edgeMaxCoord) - clip_dimensions + clip_glow);
1501
+ vec2 b = clamp(gl_Position.xy, clip_dimensions - edgeMaxCoord - clip_glow, vec2(edgeMaxCoord) + clip_glow);
1495
1502
  //flip y
1496
1503
  gl_Position.xy = mix(a, b, vec2(positions.x, 1.0 - positions.y));
1497
1504
 
@@ -1507,6 +1514,8 @@ void main(void) {
1507
1514
  DECKGL_FILTER_COLOR(vFillColor, geometry);
1508
1515
  vLineColor = vec4(instanceLineColors.rgb, instanceLineColors.a * opacity);
1509
1516
  DECKGL_FILTER_COLOR(vLineColor, geometry);
1517
+ vGlowColor = vec4(instanceGlowColors.rgb, instanceGlowColors.a * opacity);
1518
+ DECKGL_FILTER_COLOR(vGlowColor, geometry);
1510
1519
  }
1511
1520
  `;
1512
1521
 
@@ -1522,8 +1531,10 @@ uniform float cornerRadius;
1522
1531
  in vec4 vFillColor;
1523
1532
  in vec4 vLineColor;
1524
1533
  in float vLineWidth;
1534
+ in float vGlowWidth;
1525
1535
  in vec2 uv;
1526
1536
  in vec2 dimensions;
1537
+ in vec4 vGlowColor;
1527
1538
 
1528
1539
  out vec4 fragColor;
1529
1540
 
@@ -1539,17 +1550,24 @@ void main()
1539
1550
 
1540
1551
  vec2 pixelPosition = uv * dimensions;
1541
1552
 
1553
+ float fDist = RectSDF(pixelPosition-dimensions/2.0, dimensions/2.0 - vLineWidth/2.0-1.0 - vGlowWidth, cornerRadius);
1554
+ vec4 v4ToColor = (fDist < 0.0) ? vFillColor : vec4(0.0);
1555
+
1542
1556
  if (stroked) {
1543
- float fDist = RectSDF(pixelPosition-dimensions/2.0, dimensions/2.0 - vLineWidth/2.0-1.0, cornerRadius);
1544
1557
  float fBlendAmount = smoothstep(-1.0, 1.0, abs(fDist) - vLineWidth / 2.0);
1545
1558
 
1546
1559
  vec4 v4FromColor = vLineColor;
1547
- vec4 v4ToColor = (fDist < 0.0) ? vFillColor : vec4(0.0);
1548
1560
  fragColor = mix(v4FromColor, v4ToColor, fBlendAmount);
1549
1561
  } else {
1550
- fragColor = vFillColor;
1562
+ fragColor = v4ToColor;
1551
1563
  }
1552
1564
 
1565
+ // Outer glow
1566
+ if (vGlowWidth > 0.0) {
1567
+ float glowFactor = (1.0 - smoothstep(0.3*vGlowWidth, vGlowWidth*1.3, fDist - vLineWidth/2.0));
1568
+ fragColor = fragColor + vec4(vGlowColor.rgb, vGlowColor.a * glowFactor) * (1.0 - fragColor.a);
1569
+ }
1570
+
1553
1571
  DECKGL_FILTER_COLOR(fragColor, geometry);
1554
1572
  }
1555
1573
  `;
@@ -1557,6 +1575,8 @@ void main()
1557
1575
  class LabelBackgroundLayer extends layers._TextBackgroundLayer {
1558
1576
  static defaultProps = {
1559
1577
  getDragged: {type: 'accessor', value: 0.0},
1578
+ getGlowColor: {type: 'accessor', value: [0, 0, 0, 255]},
1579
+ getGlowWidth: {type: 'accessor', value: 0.0},
1560
1580
  };
1561
1581
 
1562
1582
  initializeState() {
@@ -1571,6 +1591,19 @@ void main()
1571
1591
  // return this.parent.props.getDragged(object, info);
1572
1592
  //}
1573
1593
  },
1594
+ instanceGlowColors: {
1595
+ size: 4,
1596
+ transition: true,
1597
+ type: 'unorm8',
1598
+ accessor: 'getGlowColor',
1599
+ defaultValue: [0, 0, 0, 255]
1600
+ },
1601
+ instanceGlowWidths: {
1602
+ size: 1,
1603
+ transition: false,
1604
+ accessor: "getGlowWidth",
1605
+ defaultValue: 0.0
1606
+ },
1574
1607
  });
1575
1608
  }
1576
1609
 
@@ -1817,6 +1850,8 @@ void main(void) {
1817
1850
  getLineSourceFillOffset: {type: 'accessor', value: 0},
1818
1851
  getRadius: {type: 'accessor', value: 0},
1819
1852
  getDragged: {type: 'accessor', value: 0.0},
1853
+ getGlowColor: {type: 'accessor', value: [0, 0, 0, 255]},
1854
+ getGlowWidth: {type: 'accessor', value: 0.0}
1820
1855
  }
1821
1856
 
1822
1857
  getPickingInfo(e) {
@@ -1895,6 +1930,55 @@ void main(void) {
1895
1930
  }
1896
1931
  ),
1897
1932
  //...layers,
1933
+ this.props.glow && new LabelBackgroundLayer(
1934
+ this.getSubLayerProps({
1935
+ id: 'glow',
1936
+ updateTriggers: {
1937
+ //getColor: [activeObject],
1938
+ getDragged: this.props.updateTriggers.getDragged,
1939
+ getPixelOffset: this.props.updateTriggers.getPixelOffset,
1940
+ getPosition: this.props.updateTriggers.getPosition,
1941
+ getSize: this.props.updateTriggers.getSize,
1942
+ getGlowWidth: this.props.updateTriggers.getGlowWidth,
1943
+ }
1944
+ }), {
1945
+ data: this.props.data,
1946
+ getPosition: (d, { index, data }) => {
1947
+ const pos = this.props.getPosition(d, { index, data });
1948
+ return index == (data.length - 1) ? pos : [...pos.slice(0, 2), -10];
1949
+ },
1950
+ getBoundingRect: this.getBoundingRect,
1951
+ getPixelOffset: this.props.getPixelOffset,
1952
+ getSize: this.props.getSize,
1953
+ getFillColor: (_, { index, data }) => {
1954
+ const alpha = index == (data.length - 1) ? 255 : 0;
1955
+ return [255, 255, 255, alpha];
1956
+ },
1957
+ getLineColor: (d, { index, data }) => {
1958
+ const alpha = index == (data.length - 1) ? 255: 0;
1959
+ return [...(typeof this.props.getBorderColor == "function" ? this.props.getBorderColor(d) : this.props.getBorderColor).slice(0,3), alpha];
1960
+ },
1961
+ getLineWidth: (_, { index, data }) => {
1962
+ return index == (data.length - 1) ? 1: 0;
1963
+ },
1964
+ getGlowColor: this.props.getGlowColor,
1965
+ getGlowWidth: (d, { index, data }) => {
1966
+ return index == (data.length - 1) ? this.props.getGlowWidth(d) : 0;
1967
+ },
1968
+ getDragged: this.props.getDragged,
1969
+ padding: this.props.backgroundPadding,
1970
+ edgeMaxCoord: this.props.edgeMaxCoord,
1971
+ cornerRadius: 5,
1972
+ transitions: {
1973
+ getPosition: this.props.transitions?.getPosition,
1974
+ getPixelOffset: this.props.transitions?.getPosition,
1975
+ getSize: this.props.transitions?.getSize,
1976
+ getFillColor: this.props.transitions?.getBackgroundColor,
1977
+ getLineColor: this.props.transitions?.getBorderColor,
1978
+ getLineWidth: this.props.transitions?.getBorderWidth,
1979
+ getGlowColor: this.props.transitions?.getGlowColor,
1980
+ }
1981
+ }),
1898
1982
  ...super.renderLayers(),
1899
1983
  this.state.closeData?.length && new LabelCloseButtonLayer(
1900
1984
  this.getSubLayerProps({
@@ -2317,6 +2401,9 @@ void main(void) {
2317
2401
  this.KEYS = this.model.data.space.filter(dim => dim !== this.TIMEDIM);
2318
2402
 
2319
2403
  if (this._updateLayoutProfile()) return; //return if exists with error
2404
+ // draw() can run again without rerunning the existing drawData reaction.
2405
+ // Restore pixel thicknesses before any layer uses the copied size scale.
2406
+ this._updateMarkerSizeLimits();
2320
2407
  this.addReaction(this._updateScales);
2321
2408
  this.addReaction(this.updateSize, {throttle_ms: 50});
2322
2409
  // this.addReaction(this._resetZoomMinMaxXReaction, {ignoreStatus: this._resetZoomMinMaxX});
@@ -2895,6 +2982,16 @@ void main(void) {
2895
2982
  const activeObject = this.__highlightedMarkers.size == 1 ? Object.assign({}, this.model.dataMap.get(this.__highlightedMarkers.keys().next().value)) : null;
2896
2983
  this.activeObject = activeObject?.[REQUIRED_KEY] ? null : activeObject;
2897
2984
  this.activeObjectData = this.activeObject ? [this.activeObject] : [];
2985
+ this.labelGlow = false;
2986
+ if (this.activeObject && this.__someSelected) {
2987
+ const index = this.__selectedKeys.indexOf(this.activeObject[TRAIL_KEY] || this.activeObject[KEY]);
2988
+ if (index > -1) {
2989
+ this.__selectedKeys.push(this.__selectedKeys.splice(index, 1)[0]);
2990
+ const data = this.__labelData.splice(index, 1);
2991
+ this.__labelData = [...this.__labelData, ...data];
2992
+ this.labelGlow = true;
2993
+ }
2994
+ }
2898
2995
  this.opacityUpdateTrigger++;
2899
2996
  this.deckBubble.setProps({layers: this.getBubbleLayers(undefined, false)});
2900
2997
  }
@@ -3345,6 +3442,19 @@ void main(void) {
3345
3442
  const key = d[TRAIL_KEY] || d[KEY];
3346
3443
  return this.labelDragged[key];
3347
3444
  },
3445
+ getGlowWidth: (d) => {
3446
+ if (!d) return 0;
3447
+ return this.activeObject && ((d[TRAIL_KEY] || d[KEY]) === (this.activeObject[TRAIL_KEY ] || this.activeObject[KEY])) ? 5 : 0;
3448
+ },
3449
+ getGlowColor: (d, { target }) => {
3450
+ if (!d) return;
3451
+ const c = d3.color(this.__getColor(d[TRAIL_KEY] || d[KEY], d.color)).formatRgb().slice(4, -1).split(",").map(v=>+v);
3452
+ target[0] = c[0];
3453
+ target[1] = c[1];
3454
+ target[2] = c[2];
3455
+ target[3] = 200;
3456
+ return target;
3457
+ },
3348
3458
  onLabelDragStart: ({ object:d, x, y, coordinate, sourceLayer, viewport }, evt) => {
3349
3459
  console.log("onLabelDragStart", d, x, y, coordinate, viewport, sourceLayer);
3350
3460
  if (!d) return;
@@ -3638,7 +3748,8 @@ void main(void) {
3638
3748
  updateTriggers: {
3639
3749
  getColor: [this.activeObject, this.opacityUpdateTrigger],
3640
3750
  getSourcePosition: [this.redrawUpdateTrigger],
3641
- getTargetPosition: [this.redrawUpdateTrigger]
3751
+ getTargetPosition: [this.redrawUpdateTrigger],
3752
+ getWidth: [this.redrawUpdateTrigger]
3642
3753
  },
3643
3754
  transitions: t ? {
3644
3755
  getSourcePosition: duration,
@@ -3661,7 +3772,9 @@ void main(void) {
3661
3772
  getWidth: this.props.getLastTrailLineWidth,
3662
3773
  updateTriggers: {
3663
3774
  getColor: [this.activeObject, this.opacityUpdateTrigger],
3664
- getTargetPosition: [this.redrawUpdateTrigger, this.lastLineRedrawUpdateTrigger]
3775
+ getSourcePosition: [this.redrawUpdateTrigger],
3776
+ getTargetPosition: [this.redrawUpdateTrigger, this.lastLineRedrawUpdateTrigger],
3777
+ getWidth: [this.redrawUpdateTrigger]
3665
3778
  },
3666
3779
  transitions: t ? {
3667
3780
  getTargetPosition: {
@@ -3871,6 +3984,9 @@ void main(void) {
3871
3984
  //smoothing: 0.1
3872
3985
  } : { sdf: false },
3873
3986
  //fontWeight: '500',
3987
+ glow: this.labelGlow,
3988
+ getGlowColor: this.props.getGlowColor,
3989
+ getGlowWidth: this.props.getGlowWidth,
3874
3990
  getPosition: this.props.getLabelPositionZ,
3875
3991
  getPixelOffset: this.props.getPixelOffset,
3876
3992
  getText: this.props.getLabelText,
@@ -3901,7 +4017,8 @@ void main(void) {
3901
4017
  updateTriggers: {
3902
4018
  getPixelOffset: [this.dragX, this.dragY, this.redrawUpdateTrigger],
3903
4019
  getDragged: [this.dragX0, this.dragY0],
3904
- getPosition: [this.redrawUpdateTrigger]
4020
+ getPosition: [this.redrawUpdateTrigger],
4021
+ getGlowWidth: [this.activeObject],
3905
4022
  },
3906
4023
  transitions: t ? {
3907
4024
  getPosition: {
@@ -4074,6 +4191,8 @@ void main(void) {
4074
4191
  "marker-contextmenu": {
4075
4192
  "primaryDim": null,
4076
4193
  "drilldown": null,
4194
+ "allowExplodeTo": [],
4195
+ "allowFoldTo": []
4077
4196
  },
4078
4197
  "chart": {
4079
4198
  "show_ticks": true,
@@ -4256,7 +4375,7 @@ void main(void) {
4256
4375
  },
4257
4376
  };
4258
4377
 
4259
- BubbleChart.versionInfo = { version: "5.5.3", build: 1768916445428, package: {"homepage":"https://github.com/vizabi/bubblechart#readme","name":"@vizabi/bubblechart","description":"Vizabi bubble chart"}, sharedComponents: sharedComponents.versionInfo};
4378
+ BubbleChart.versionInfo = { version: "5.5.5", build: 1791750840591, package: {"homepage":"https://github.com/vizabi/bubblechart#readme","name":"@vizabi/bubblechart","description":"Vizabi bubble chart"}, sharedComponents: sharedComponents.versionInfo};
4260
4379
 
4261
4380
  exports.Base = BubbleChart;
4262
4381