@vizabi/bubblechart 3.16.3 → 3.17.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.
- package/build/bubblechart.css +1 -0
- package/build/bubblechart.js +59 -25
- package/build/bubblechart.js.map +1 -1
- package/build/stats.html +1 -1
- package/package.json +1 -1
package/build/bubblechart.css
CHANGED
|
@@ -484,6 +484,7 @@
|
|
|
484
484
|
.vzb-tool .vzb-bubblechart .vzb-bubblechart-svg .vzb-bc-decorations .vzb-bc-line-equal-xy {
|
|
485
485
|
stroke-dasharray: 4 4;
|
|
486
486
|
stroke: #333;
|
|
487
|
+
fill: none;
|
|
487
488
|
}
|
|
488
489
|
.vzb-tool .vzb-bubblechart .vzb-bubblechart-svg .vzb-bc-decorations .vzb-bc-x-axis-groups text {
|
|
489
490
|
fill: #999;
|
package/build/bubblechart.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// https://github.com/vizabi/bubblechart#readme v3.
|
|
1
|
+
// https://github.com/vizabi/bubblechart#readme v3.17.1 build 1684874653888 Copyright 2023 Gapminder Foundation and contributors
|
|
2
2
|
(function (global, factory) {
|
|
3
3
|
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('@vizabi/shared-components'), require('d3'), require('mobx')) :
|
|
4
4
|
typeof define === 'function' && define.amd ? define(['@vizabi/shared-components', 'd3', 'mobx'], factory) :
|
|
@@ -843,17 +843,27 @@
|
|
|
843
843
|
&& layoutProfile !== "SMALL";
|
|
844
844
|
|
|
845
845
|
this.DOM.lineEqualXY.classed("vzb-invisible", !showLineEqualXY);
|
|
846
|
+
|
|
846
847
|
if (showLineEqualXY) {
|
|
847
|
-
|
|
848
|
-
|
|
848
|
+
this.MDL.x.scale.type; //watch
|
|
849
|
+
this.MDL.y.scale.type; //watch
|
|
850
|
+
|
|
851
|
+
const domains = this.yScale.domain().concat(this.xScale.domain()),
|
|
852
|
+
min = d3.min(domains),
|
|
853
|
+
max = d3.max(domains),
|
|
854
|
+
step = (max-min)/100;
|
|
855
|
+
|
|
856
|
+
const sequence = d3.range(min, max, step).concat(max);
|
|
857
|
+
|
|
858
|
+
const line = d3.line()
|
|
859
|
+
.curve(d3.curveBasis)
|
|
860
|
+
.x(d => this.xScale(d))
|
|
861
|
+
.y(d => this.yScale(d));
|
|
849
862
|
|
|
850
863
|
this.DOM.lineEqualXY
|
|
851
864
|
.transition()
|
|
852
865
|
.duration(duration || 0)
|
|
853
|
-
.attr("
|
|
854
|
-
.attr("y2", this.yScale(max) || 0)
|
|
855
|
-
.attr("x1", this.xScale(min) || 0)
|
|
856
|
-
.attr("x2", this.xScale(max) || 0);
|
|
866
|
+
.attr("d", line(sequence));
|
|
857
867
|
}
|
|
858
868
|
}
|
|
859
869
|
}
|
|
@@ -861,6 +871,7 @@
|
|
|
861
871
|
const {ICON_QUESTION} = sharedComponents.Icons;
|
|
862
872
|
const COLOR_WHITEISH = "rgb(253, 253, 253)";
|
|
863
873
|
const COLOR_BLACKISH = "rgb(51, 51, 51)";
|
|
874
|
+
const THICK_LINE_THRESHOLD_FOR_DARKER_COLOR = 3;
|
|
864
875
|
|
|
865
876
|
const marginScaleH = (marginMin, ratio = 0) => height => marginMin + height * ratio;
|
|
866
877
|
const marginScaleW = (marginMin, ratio = 0) => width => marginMin + width * ratio;
|
|
@@ -878,6 +889,8 @@
|
|
|
878
889
|
padding: 2,
|
|
879
890
|
minRadiusPx: 0.5,
|
|
880
891
|
maxRadiusPx: Math.max(0.5, MAX_RADIUS_EM * sharedComponents.LegacyUtils.hypotenuse(width, height)),
|
|
892
|
+
minTrailThicknessPx: 1,
|
|
893
|
+
maxTrailThicknessPx: 4,
|
|
881
894
|
infoElHeight: 16,
|
|
882
895
|
yAxisTitleBottomMargin: 6,
|
|
883
896
|
xAxisTitleBottomMargin: 4
|
|
@@ -888,6 +901,8 @@
|
|
|
888
901
|
padding: 2,
|
|
889
902
|
minRadiusPx: 1,
|
|
890
903
|
maxRadiusPx: Math.max(0.5, MAX_RADIUS_EM * sharedComponents.LegacyUtils.hypotenuse(width, height)),
|
|
904
|
+
minTrailThicknessPx: 2,
|
|
905
|
+
maxTrailThicknessPx: 6,
|
|
891
906
|
infoElHeight: 20,
|
|
892
907
|
yAxisTitleBottomMargin: 3,
|
|
893
908
|
xAxisTitleBottomMargin: 4
|
|
@@ -898,6 +913,8 @@
|
|
|
898
913
|
padding: 2,
|
|
899
914
|
minRadiusPx: 1,
|
|
900
915
|
maxRadiusPx: Math.max(0.5, MAX_RADIUS_EM * sharedComponents.LegacyUtils.hypotenuse(width, height)),
|
|
916
|
+
minTrailThicknessPx: 2,
|
|
917
|
+
maxTrailThicknessPx: 8,
|
|
901
918
|
infoElHeight: 22,
|
|
902
919
|
yAxisTitleBottomMargin: 3,//marginScaleH(4, 0.01)(height),
|
|
903
920
|
xAxisTitleBottomMargin: marginScaleH(0, 0.01)(height),
|
|
@@ -979,7 +996,7 @@
|
|
|
979
996
|
<g class="vzb-bc-graph">
|
|
980
997
|
<svg class="vzb-bc-bubbles-crop">
|
|
981
998
|
<g class="vzb-bc-decorations">
|
|
982
|
-
<
|
|
999
|
+
<path class="vzb-bc-line-equal-xy vzb-invisible"></path>
|
|
983
1000
|
<g class="vzb-bc-x-axis-groups"></g>
|
|
984
1001
|
</g>
|
|
985
1002
|
<g class="vzb-bc-lines"></g>
|
|
@@ -1194,6 +1211,7 @@
|
|
|
1194
1211
|
//this.MDL.trail.config.show = false;
|
|
1195
1212
|
//this.ui.cursorMode = "plus";
|
|
1196
1213
|
this.sScale = this.MDL.size.scale.d3Scale;
|
|
1214
|
+
this.trailSizeScale = this.MDL.size.scale.d3Scale.copy();
|
|
1197
1215
|
|
|
1198
1216
|
this.TIMEDIM = this.MDL.frame.data.concept;
|
|
1199
1217
|
this.KEYS = this.model.data.space.filter(dim => dim !== this.TIMEDIM);
|
|
@@ -1271,10 +1289,14 @@
|
|
|
1271
1289
|
}
|
|
1272
1290
|
|
|
1273
1291
|
__getColor(key, valueC) {
|
|
1274
|
-
return valueC != null && !sharedComponents.LegacyUtils.isNaN(valueC)
|
|
1292
|
+
return valueC != null && !sharedComponents.LegacyUtils.isNaN(valueC)
|
|
1293
|
+
? (this.MDL.color.scale.isPattern ? `url(#flag-${key}-${this.id})` : this.cScale(valueC))
|
|
1294
|
+
: COLOR_WHITEISH;
|
|
1275
1295
|
}
|
|
1276
|
-
__getColorForTrail(
|
|
1277
|
-
|
|
1296
|
+
__getColorForTrail(valueC, valueS) {
|
|
1297
|
+
if(valueC == null || sharedComponents.LegacyUtils.isNaN(valueC) || this.MDL.color.scale.isPattern) return COLOR_BLACKISH;
|
|
1298
|
+
if(this.trailSizeScale(valueS) > THICK_LINE_THRESHOLD_FOR_DARKER_COLOR) return this.cScale(valueC);
|
|
1299
|
+
return this.MDL.color.scale.palette.getColorShade({colorID: valueC}) || COLOR_BLACKISH;
|
|
1278
1300
|
}
|
|
1279
1301
|
|
|
1280
1302
|
_createAndDeleteBubbles() {
|
|
@@ -1378,16 +1400,19 @@
|
|
|
1378
1400
|
|
|
1379
1401
|
const scaledX0 = _this.xScale(dataNext[_this._alias("x")]);
|
|
1380
1402
|
const scaledY0 = _this.yScale(dataNext[_this._alias("y")]);
|
|
1381
|
-
const scaledCT = _this.__getColorForTrail(dataNext
|
|
1403
|
+
const scaledCT = _this.__getColorForTrail(dataNext.color, dataNext.size);
|
|
1404
|
+
|
|
1405
|
+
const nextR = sharedComponents.LegacyUtils.areaToRadius(_this.sScale(dataNext.size || 0));
|
|
1406
|
+
const length = Math.sqrt( (scaledX - scaledX0)**2 + (scaledY - scaledY0)**2 ) - d.r - nextR;
|
|
1382
1407
|
|
|
1383
1408
|
trailLine
|
|
1384
1409
|
.attr("x1", scaledX)
|
|
1385
1410
|
.attr("y1", scaledY)
|
|
1386
1411
|
.attr("x2", scaledX0)
|
|
1387
1412
|
.attr("y2", scaledY0)
|
|
1388
|
-
.attr("stroke-dasharray",
|
|
1389
|
-
.
|
|
1390
|
-
.style("stroke",
|
|
1413
|
+
.attr("stroke-dasharray", `0 ${d.r} ${length > 0 ? length : 0} ${nextR}`)
|
|
1414
|
+
.style("stroke-width", _this.trailSizeScale(dataNext.size))
|
|
1415
|
+
.style("stroke", scaledCT);
|
|
1391
1416
|
}
|
|
1392
1417
|
}
|
|
1393
1418
|
|
|
@@ -1467,7 +1492,7 @@
|
|
|
1467
1492
|
const trailLine = group.select(".vzb-trail-line");
|
|
1468
1493
|
const scaledX0 = _this.xScale(dataNext[_this._alias("x")]);
|
|
1469
1494
|
const scaledY0 = _this.yScale(dataNext[_this._alias("y")]);
|
|
1470
|
-
const scaledCT = _this.__getColorForTrail(dataNext
|
|
1495
|
+
const scaledCT = _this.__getColorForTrail(dataNext.color, dataNext.size);
|
|
1471
1496
|
|
|
1472
1497
|
trailLine
|
|
1473
1498
|
.attr("x1", scaledX)
|
|
@@ -1485,10 +1510,13 @@
|
|
|
1485
1510
|
.attr("y2", scaledY0);
|
|
1486
1511
|
}
|
|
1487
1512
|
|
|
1513
|
+
const nextR = sharedComponents.LegacyUtils.areaToRadius(_this.sScale(dataNext.size || 0));
|
|
1514
|
+
const length = Math.sqrt( (scaledX - scaledX0)**2 + (scaledY - scaledY0)**2 ) - d.r - nextR;
|
|
1515
|
+
|
|
1488
1516
|
trailLine
|
|
1489
|
-
.style("stroke",
|
|
1490
|
-
.
|
|
1491
|
-
.attr("stroke-
|
|
1517
|
+
.style("stroke", scaledCT)
|
|
1518
|
+
.style("stroke-width", _this.trailSizeScale(dataNext.size))
|
|
1519
|
+
.attr("stroke-dasharray", `0 ${d.r} ${length > 0 ? length : 0} ${nextR}`);
|
|
1492
1520
|
}
|
|
1493
1521
|
}
|
|
1494
1522
|
|
|
@@ -1599,16 +1627,19 @@
|
|
|
1599
1627
|
const dataNext = data[index + 1];
|
|
1600
1628
|
const scaledX0 = _this.xScale(dataNext[_this._alias("x")]);
|
|
1601
1629
|
const scaledY0 = _this.yScale(dataNext[_this._alias("y")]);
|
|
1602
|
-
const scaledCT = _this.__getColorForTrail(dataNext
|
|
1630
|
+
const scaledCT = _this.__getColorForTrail(dataNext.color, dataNext.size);
|
|
1631
|
+
|
|
1632
|
+
const nextR = sharedComponents.LegacyUtils.areaToRadius(_this.sScale(dataNext.size || 0));
|
|
1633
|
+
const length = Math.sqrt( (scaledX - scaledX0)**2 + (scaledY - scaledY0)**2 ) - d.r - nextR;
|
|
1603
1634
|
|
|
1604
1635
|
trailLine
|
|
1605
1636
|
.attr("x1", scaledX)
|
|
1606
1637
|
.attr("y1", scaledY)
|
|
1607
1638
|
.attr("x2", scaledX0)
|
|
1608
1639
|
.attr("y2", scaledY0)
|
|
1609
|
-
.style("stroke",
|
|
1610
|
-
.
|
|
1611
|
-
.attr("stroke-
|
|
1640
|
+
.style("stroke", scaledCT)
|
|
1641
|
+
.style("stroke-width", _this.trailSizeScale(dataNext.size))
|
|
1642
|
+
.attr("stroke-dasharray", `0 ${d.r} ${length > 0 ? length : 0} ${nextR}`);
|
|
1612
1643
|
}
|
|
1613
1644
|
});
|
|
1614
1645
|
|
|
@@ -2155,7 +2186,9 @@
|
|
|
2155
2186
|
|
|
2156
2187
|
const {
|
|
2157
2188
|
minRadiusPx,
|
|
2158
|
-
maxRadiusPx
|
|
2189
|
+
maxRadiusPx,
|
|
2190
|
+
minTrailThicknessPx,
|
|
2191
|
+
maxTrailThicknessPx,
|
|
2159
2192
|
} = this.profileConstants;
|
|
2160
2193
|
|
|
2161
2194
|
//transfer min max radius to size dialog via root ui observable (probably a cleaner way is possible)
|
|
@@ -2170,6 +2203,7 @@
|
|
|
2170
2203
|
d3.range(minArea, maxArea, (maxArea - minArea)/(this.sScale.domain().length - 1)).concat(maxArea);
|
|
2171
2204
|
|
|
2172
2205
|
this.sScale.range(range);
|
|
2206
|
+
this.trailSizeScale.domain(this.MDL.size.scale.domain).range([minTrailThicknessPx, maxTrailThicknessPx]);
|
|
2173
2207
|
}
|
|
2174
2208
|
|
|
2175
2209
|
_setTooltip(tooltipText, x, y, s, c, d) {
|
|
@@ -2752,7 +2786,7 @@
|
|
|
2752
2786
|
}
|
|
2753
2787
|
});
|
|
2754
2788
|
|
|
2755
|
-
BubbleChart.versionInfo = { version: "3.
|
|
2789
|
+
BubbleChart.versionInfo = { version: "3.17.1", build: 1684874653888, package: {"homepage":"https://github.com/vizabi/bubblechart#readme","name":"@vizabi/bubblechart","description":"Vizabi bubble chart"}, sharedComponents: sharedComponents.versionInfo};
|
|
2756
2790
|
|
|
2757
2791
|
return BubbleChart;
|
|
2758
2792
|
|