@vizabi/bubblechart 3.14.0 → 3.14.1

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 v3.14.0 build 1642809388634 Copyright 2022 Gapminder Foundation and contributors
1
+ // https://github.com/vizabi/bubblechart#readme v3.14.1 build 1645171739593 Copyright 2022 Gapminder Foundation and contributors
2
2
  (function (global, factory) {
3
3
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('VizabiSharedComponents'), require('mobx')) :
4
4
  typeof define === 'function' && define.amd ? define(['VizabiSharedComponents', 'mobx'], factory) :
@@ -1091,6 +1091,7 @@
1091
1091
  this.draggingNow = null;
1092
1092
 
1093
1093
  this.hoverBubble = false;
1094
+ this.__lastStep = 0;
1094
1095
 
1095
1096
  const _this = this;
1096
1097
  //keyboard listeners
@@ -1216,6 +1217,7 @@
1216
1217
  this.addReaction(this._updateYear);
1217
1218
  this.addReaction(this.drawData);
1218
1219
  this.addReaction(this._zoomToMarkerMaxMin);
1220
+ this.addReaction(this.redrawData);
1219
1221
 
1220
1222
  this.addReaction(this._selectDataPoints);
1221
1223
  this.addReaction(this._highlightDataPoints);
@@ -1285,6 +1287,11 @@
1285
1287
  const duration = this._getDuration();
1286
1288
  const transition = this._getTransition(duration);
1287
1289
  const data = this.__dataProcessed;
1290
+ let trailRedrawDate;
1291
+
1292
+ mobx.runInAction(()=>{
1293
+ trailRedrawDate = this.MDL.frame.stepScale.invert(Math.min(this.__lastStep, this.__lastStep = this.MDL.frame.step << 0) - 1);
1294
+ });
1288
1295
 
1289
1296
  this.bubbles = this.DOM.bubbleContainer.selectAll(".vzb-bc-entity")
1290
1297
  .data(this.__dataProcessed, d => d[Symbol.for("key")])
@@ -1406,13 +1413,11 @@
1406
1413
  const isTrail = isTrailBubble(d);
1407
1414
  const isExtrapolated = d[Symbol.for("extrapolated")];
1408
1415
  const dataNext = data[index + 1] || {};
1409
- const dataNext2 = data[index + 2] || {};
1410
1416
  const headTrail = isTrail && !dataNext[Symbol.for("trailHeadKey")];
1411
- const headTrail2 = isTrail && !dataNext2[Symbol.for("trailHeadKey")];
1412
1417
 
1413
1418
  const valueS = d.size;
1414
1419
  d.r = VizabiSharedComponents.LegacyUtils.areaToRadius(_this.sScale(valueS || 0));
1415
- if (isTrail && !headTrail && !headTrail2) return;
1420
+ if (isTrail && d["frame"] < trailRedrawDate) return;
1416
1421
 
1417
1422
  const valueX = d[_this._alias("x")];
1418
1423
  const valueY = d[_this._alias("y")];
@@ -1425,19 +1430,24 @@
1425
1430
  const scaledY = _this.yScale(valueY);
1426
1431
  const scaledC = _this.__getColor(d[Symbol.for(isTrail ? "trailHeadKey" : "key")], valueC);
1427
1432
 
1433
+ const group = d3.select(this);
1428
1434
  if (!duration || !headTrail) {
1429
- const view = duration && !isTrail ?
1430
- d3.select(this).transition(transition)
1431
- :
1432
- d3.select(this).interrupt();
1433
-
1434
- view.select("circle")
1435
- .attr("r", d.r)
1436
- .attr("fill", scaledC)
1437
- .attr("cy", scaledY)
1438
- .attr("cx", scaledX);
1435
+ const circle = group.select("circle");
1436
+ if (duration && !isTrail) {
1437
+ circle.transition(transition)
1438
+ .attr("r", d.r)
1439
+ .attr("fill", scaledC)
1440
+ .attr("cy", scaledY)
1441
+ .attr("cx", scaledX);
1442
+ } else {
1443
+ circle.interrupt()
1444
+ .attr("r", d.r)
1445
+ .attr("fill", scaledC)
1446
+ .attr("cy", scaledY)
1447
+ .attr("cx", scaledX);
1448
+ }
1439
1449
 
1440
- const diagonalLine = d3.select(this).select(".vzb-diagonal-line");
1450
+ const diagonalLine = group.select(".vzb-diagonal-line");
1441
1451
  diagonalLine
1442
1452
  .classed("vzb-hidden", !isExtrapolated);
1443
1453
  if(isExtrapolated){
@@ -1458,7 +1468,7 @@
1458
1468
 
1459
1469
  //trail line
1460
1470
  if (isTrail) {
1461
- const trailLine = d3.select(this).select(".vzb-trail-line");
1471
+ const trailLine = group.select(".vzb-trail-line");
1462
1472
  const scaledX0 = _this.xScale(dataNext[_this._alias("x")]);
1463
1473
  const scaledY0 = _this.yScale(dataNext[_this._alias("y")]);
1464
1474
 
@@ -1513,18 +1523,21 @@
1513
1523
 
1514
1524
 
1515
1525
  redrawData(duration) {
1516
- this.services.layout.size;
1517
- this.MDL.x.scale.type;
1518
- this.MDL.y.scale.type;
1526
+ //this.services.layout.size;
1527
+ //this.MDL.x.scale.type;
1528
+ //this.MDL.y.scale.type;
1519
1529
  this.MDL.color.scale.type;
1520
1530
  this.MDL.size.scale.type;
1521
1531
  this.MDL.size.scale.extent;
1522
1532
 
1523
1533
  const _this = this;
1524
1534
  const data = this.__dataProcessed;
1535
+ const transition = this._getTransition(duration);
1525
1536
 
1526
1537
  if (this.bubbles) this.bubbles.each(function(d, index) {
1527
1538
  const isTrail = isTrailBubble(d);
1539
+ const dataNext = data[index + 1] || {};
1540
+ const headTrail = isTrail && !dataNext[Symbol.for("trailHeadKey")];
1528
1541
  const isExtrapolated = d[Symbol.for("extrapolated")];
1529
1542
 
1530
1543
  const valueX = d[_this._alias("x")];
@@ -1537,24 +1550,35 @@
1537
1550
  const scaledY = _this.yScale(valueY);
1538
1551
  const scaledC = _this.__getColor(d[Symbol.for(isTrail ? "trailHeadKey" : "key")], valueC);
1539
1552
 
1540
- const view = duration ?
1541
- d3.select(this)
1542
- .transition()
1543
- .duration(duration)
1544
- : d3.select(this).interrupt();
1553
+ const group = d3.select(this);
1545
1554
 
1546
- view.select("circle")
1547
- .attr("r", d.r)
1548
- .attr("fill", scaledC)
1549
- .attr("cy", scaledY)
1550
- .attr("cx", scaledX);
1555
+ if (duration && headTrail) {
1556
+ group.style("opacity", 0)
1557
+ .transition().delay(duration).duration(0)
1558
+ .style("opacity", d[Symbol.for("opacity")]);
1559
+ }
1560
+
1561
+ const circle = group.select("circle");
1562
+ if (duration && !headTrail) {
1563
+ circle.transition(transition)
1564
+ .attr("r", d.r)
1565
+ .attr("fill", scaledC)
1566
+ .attr("cy", scaledY)
1567
+ .attr("cx", scaledX);
1568
+ } else {
1569
+ circle.interrupt()
1570
+ .attr("r", d.r)
1571
+ .attr("fill", scaledC)
1572
+ .attr("cy", scaledY)
1573
+ .attr("cx", scaledX);
1574
+ }
1551
1575
 
1552
- const diagonalLine = d3.select(this).select(".vzb-diagonal-line");
1576
+ const diagonalLine = group.select(".vzb-diagonal-line");
1553
1577
  diagonalLine
1554
1578
  .classed("vzb-hidden", !isExtrapolated);
1555
1579
  if(isExtrapolated){
1556
- if (duration){
1557
- diagonalLine.transition().duration(duration)
1580
+ if (duration && !headTrail){
1581
+ diagonalLine.transition(transition)
1558
1582
  .attr("x1", scaledX + d.r/Math.sqrt(2))
1559
1583
  .attr("y1", scaledY + d.r/Math.sqrt(2))
1560
1584
  .attr("x2", scaledX - d.r/Math.sqrt(2))
@@ -1570,11 +1594,10 @@
1570
1594
 
1571
1595
 
1572
1596
  if (isTrail) {
1573
- const trailLine = duration ?
1574
- d3.select(this).select(".vzb-trail-line")
1575
- .transition()
1576
- .duration(duration)
1577
- : d3.select(this).select(".vzb-trail-line").interrupt();
1597
+ const trailLine = (duration && !headTrail) ?
1598
+ group.select(".vzb-trail-line")
1599
+ .transition(transition)
1600
+ : group.select(".vzb-trail-line").interrupt();
1578
1601
 
1579
1602
  const dataNext = data[index + 1];
1580
1603
  const scaledX0 = _this.xScale(dataNext[_this._alias("x")]);
@@ -1591,7 +1614,7 @@
1591
1614
  }
1592
1615
  });
1593
1616
 
1594
- _this._updateLabels();
1617
+ mobx.runInAction(() => _this._updateLabels(duration));
1595
1618
  }
1596
1619
 
1597
1620
  __getZoomed(type, zoomed, domain) {
@@ -2471,7 +2494,7 @@
2471
2494
  }
2472
2495
  }
2473
2496
 
2474
- _updateLabels() {
2497
+ _updateLabels(duration) {
2475
2498
  //console.log("updateLabels");
2476
2499
 
2477
2500
  const selectedFilter = this.MDL.selected.data.filter;
@@ -2498,7 +2521,7 @@
2498
2521
  cache.valueS0 = d.size;
2499
2522
  cache.initTextBBox = null;
2500
2523
  cache.initFontSize = null;
2501
- this._labels.updateLabel({ [Symbol.for("key")]: key }, null, null, null, null, null, null, d.size_label);
2524
+ this._labels.updateLabel({ [Symbol.for("key")]: key }, null, null, null, null, null, null, d.size_label, duration);
2502
2525
  }
2503
2526
  }
2504
2527
 
@@ -2723,7 +2746,7 @@
2723
2746
  }
2724
2747
  });
2725
2748
 
2726
- BubbleChart.versionInfo = { version: "3.14.0", build: 1642809388634, package: {"homepage":"https://github.com/vizabi/bubblechart#readme","name":"@vizabi/bubblechart","description":"Vizabi bubble chart"}, sharedComponents: VizabiSharedComponents.versionInfo};
2749
+ BubbleChart.versionInfo = { version: "3.14.1", build: 1645171739593, package: {"homepage":"https://github.com/vizabi/bubblechart#readme","name":"@vizabi/bubblechart","description":"Vizabi bubble chart"}, sharedComponents: VizabiSharedComponents.versionInfo};
2727
2750
 
2728
2751
  return BubbleChart;
2729
2752