@vizabi/bubblechart 3.12.1 → 3.14.0
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 +3 -8
- package/build/bubblechart.js +72 -33
- package/build/bubblechart.js.map +1 -1
- package/build/stats.html +1 -1
- package/package.json +1 -1
package/build/bubblechart.css
CHANGED
|
@@ -171,22 +171,20 @@
|
|
|
171
171
|
.vzb-tool .vzb-bubblechart .vzb-bubblechart-svg .vzb-bc-axis-y-subtitle .tick-minor,
|
|
172
172
|
.vzb-tool .vzb-bubblechart .vzb-bubblechart-svg .vzb-bc-axis-x .tick-minor,
|
|
173
173
|
.vzb-tool .vzb-bubblechart .vzb-bubblechart-svg .vzb-bc-axis-y .tick-minor {
|
|
174
|
-
stroke
|
|
174
|
+
stroke: #d6d6d6;
|
|
175
175
|
}
|
|
176
176
|
.vzb-tool.vzb-medium .vzb-bubblechart-svg .vzb-bc-axis-x .tick line,
|
|
177
177
|
.vzb-tool.vzb-medium .vzb-bubblechart-svg .vzb-bc-axis-y .tick line,
|
|
178
178
|
.vzb-tool.vzb-medium .vzb-bubblechart-svg .vzb-bc-axis-x .tick-minor,
|
|
179
179
|
.vzb-tool.vzb-medium .vzb-bubblechart-svg .vzb-bc-axis-y .tick-minor {
|
|
180
|
-
stroke: #
|
|
181
|
-
stroke-dasharray: 1 6;
|
|
180
|
+
stroke: #d6d6d6;
|
|
182
181
|
}
|
|
183
182
|
|
|
184
183
|
.vzb-tool.vzb-large .vzb-bubblechart-svg .vzb-bc-axis-x .tick line,
|
|
185
184
|
.vzb-tool.vzb-large .vzb-bubblechart-svg .vzb-bc-axis-y .tick line,
|
|
186
185
|
.vzb-tool.vzb-large .vzb-bubblechart-svg .vzb-bc-axis-x .tick-minor,
|
|
187
186
|
.vzb-tool.vzb-large .vzb-bubblechart-svg .vzb-bc-axis-y .tick-minor {
|
|
188
|
-
stroke: #
|
|
189
|
-
stroke-dasharray: none;
|
|
187
|
+
stroke: #d6d6d6;
|
|
190
188
|
}
|
|
191
189
|
|
|
192
190
|
.vzb-tool.vzb-presentation .vzb-bubblechart-svg .vzb-bc-axis-x .tick line,
|
|
@@ -194,7 +192,6 @@
|
|
|
194
192
|
.vzb-tool.vzb-presentation .vzb-bubblechart-svg .vzb-bc-axis-x .tick-minor,
|
|
195
193
|
.vzb-tool.vzb-presentation .vzb-bubblechart-svg .vzb-bc-axis-y .tick-minor {
|
|
196
194
|
stroke: none;
|
|
197
|
-
stroke-dasharray: none;
|
|
198
195
|
}
|
|
199
196
|
|
|
200
197
|
.vzb-tool .vzb-bubblechart .vzb-bubblechart-svg .vzb-bc-axis-x-info,
|
|
@@ -512,8 +509,6 @@
|
|
|
512
509
|
stroke-width: 1px;
|
|
513
510
|
}
|
|
514
511
|
.vzb-tool .vzb-bubblechart .vzb-bubblechart-svg .vzb-bc-date {
|
|
515
|
-
filter: alpha(opacity=30);
|
|
516
|
-
opacity: 0.3;
|
|
517
512
|
font-size: 15em;
|
|
518
513
|
fill: #999;
|
|
519
514
|
text-anchor: middle;
|
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.14.0 build 1642809388634 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) :
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
// this.dragLock = false;
|
|
17
17
|
|
|
18
18
|
this.dragRectangle
|
|
19
|
+
.filter(event => !event.button)
|
|
19
20
|
.subject(this.dragSubject())
|
|
20
21
|
.on("start", this.drag().start)
|
|
21
22
|
.on("drag", this.drag().go)
|
|
@@ -54,8 +55,8 @@
|
|
|
54
55
|
}
|
|
55
56
|
|
|
56
57
|
return {
|
|
57
|
-
x: d3.pointer(event)[0],
|
|
58
|
-
y: d3.pointer(event)[1]
|
|
58
|
+
x: d3.pointer(event, this)[0],
|
|
59
|
+
y: d3.pointer(event, this)[1]
|
|
59
60
|
};
|
|
60
61
|
};
|
|
61
62
|
}
|
|
@@ -80,8 +81,8 @@
|
|
|
80
81
|
|
|
81
82
|
// self.dragLock = true;
|
|
82
83
|
this.origin = {
|
|
83
|
-
x: d3.pointer(event)[0],
|
|
84
|
-
y: d3.pointer(event)[1]
|
|
84
|
+
x: d3.pointer(event, this)[0],
|
|
85
|
+
y: d3.pointer(event, this)[1]
|
|
85
86
|
};
|
|
86
87
|
_this.DOM.zoomRect.classed("vzb-invisible", false);
|
|
87
88
|
},
|
|
@@ -110,8 +111,8 @@
|
|
|
110
111
|
.classed("vzb-invisible", true);
|
|
111
112
|
|
|
112
113
|
this.target = {
|
|
113
|
-
x: d3.pointer(event)[0],
|
|
114
|
-
y: d3.pointer(event)[1]
|
|
114
|
+
x: d3.pointer(event, this)[0],
|
|
115
|
+
y: d3.pointer(event, this)[1]
|
|
115
116
|
};
|
|
116
117
|
if (Math.abs(this.origin.x - this.target.x) < 10 || Math.abs(this.origin.y - this.target.y) < 10) return;
|
|
117
118
|
|
|
@@ -647,7 +648,7 @@
|
|
|
647
648
|
let ratio = transform.k;
|
|
648
649
|
const pan = [transform.x, transform.y];
|
|
649
650
|
|
|
650
|
-
const mouse = d3.pointer(event);
|
|
651
|
+
const mouse = d3.pointer(event, this.zoomSelection.node());
|
|
651
652
|
let k = Math.log(ratio) / Math.LN2;
|
|
652
653
|
|
|
653
654
|
//change factor direction based on the input. default is no direction supplied
|
|
@@ -965,7 +966,7 @@
|
|
|
965
966
|
<rect class="vzb-bc-eventarea"></rect>
|
|
966
967
|
<g class="vzb-bc-trails"></g>
|
|
967
968
|
<g class="vzb-bc-bubbles"></g>
|
|
968
|
-
<rect class="vzb-bc-forecastoverlay vzb-hidden" x="0" y="0" width="100%" height="100%" fill="url(#vzb-bc-pattern-lines)" pointer-events='none'></rect>
|
|
969
|
+
<rect class="vzb-bc-forecastoverlay vzb-hidden" x="0" y="0" width="100%" height="100%" fill="url(#vzb-bc-pattern-lines-${config.id})" pointer-events='none'></rect>
|
|
969
970
|
</svg>
|
|
970
971
|
|
|
971
972
|
<g class="vzb-bc-axis-y-subtitle"><text></text></g>
|
|
@@ -997,10 +998,10 @@
|
|
|
997
998
|
</svg>
|
|
998
999
|
<svg width="0" height="0">
|
|
999
1000
|
<defs>
|
|
1000
|
-
<filter id="vzb-glow-filter" x="-50%" y="-50%" width="200%" height="200%">
|
|
1001
|
+
<filter id="vzb-glow-filter-${config.id}" x="-50%" y="-50%" width="200%" height="200%">
|
|
1001
1002
|
<feGaussianBlur in="SourceGraphic" stdDeviation="2"></feGaussianBlur>
|
|
1002
1003
|
</filter>
|
|
1003
|
-
<pattern id="vzb-bc-pattern-lines" x="0" y="0" patternUnits="userSpaceOnUse" width="50" height="50" viewBox="0 0 10 10">
|
|
1004
|
+
<pattern id="vzb-bc-pattern-lines-${config.id}" x="0" y="0" patternUnits="userSpaceOnUse" width="50" height="50" viewBox="0 0 10 10">
|
|
1004
1005
|
<path d='M-1,1 l2,-2M0,10 l10,-10M9,11 l2,-2' stroke='black' stroke-width='3' opacity='0.08'/>
|
|
1005
1006
|
</pattern>
|
|
1006
1007
|
</defs>
|
|
@@ -1025,7 +1026,8 @@
|
|
|
1025
1026
|
zoomRect: this.element.select(".vzb-bc-zoom-rect"),
|
|
1026
1027
|
eventArea: this.element.select(".vzb-bc-eventarea"),
|
|
1027
1028
|
forecastOverlay: this.element.select(".vzb-bc-forecastoverlay"),
|
|
1028
|
-
tooltipMobile: this.element.select(".vzb-tooltip-mobile")
|
|
1029
|
+
tooltipMobile: this.element.select(".vzb-tooltip-mobile"),
|
|
1030
|
+
defs: this.element.select("defs")
|
|
1029
1031
|
};
|
|
1030
1032
|
this.DOM.chartSvg.select(".vzb-bc-graph").call(graph =>
|
|
1031
1033
|
Object.assign(this.DOM, {
|
|
@@ -1070,7 +1072,7 @@
|
|
|
1070
1072
|
|
|
1071
1073
|
//set filter
|
|
1072
1074
|
this.DOM.bubbleCrown.selectAll(".vzb-crown-glow")
|
|
1073
|
-
.attr("filter",
|
|
1075
|
+
.attr("filter", `url(${location.pathname}#vzb-glow-filter-${this.id})`);
|
|
1074
1076
|
|
|
1075
1077
|
this._date = this.findChild({type: "DateTimeBackground"});
|
|
1076
1078
|
this._labels = this.findChild({type: "Labels"});
|
|
@@ -1191,7 +1193,7 @@
|
|
|
1191
1193
|
}
|
|
1192
1194
|
|
|
1193
1195
|
draw() {
|
|
1194
|
-
this.localise = this.services.locale.auto();
|
|
1196
|
+
this.localise = this.services.locale.auto(this.MDL.frame.interval);
|
|
1195
1197
|
|
|
1196
1198
|
//this.MDL.trail.config.show = false;
|
|
1197
1199
|
//this.ui.cursorMode = "plus";
|
|
@@ -1209,6 +1211,7 @@
|
|
|
1209
1211
|
// this.addReaction(this._resetZoomMinMaxXReaction, this._resetZoomMinMaxX);
|
|
1210
1212
|
// this.addReaction(this._resetZoomMinMaxYReaction, this._resetZoomMinMaxY);
|
|
1211
1213
|
this.addReaction(this._updateOpacity);
|
|
1214
|
+
this.addReaction(this.updateColorPatterns);
|
|
1212
1215
|
this.addReaction(this._updateShowYear);
|
|
1213
1216
|
this.addReaction(this._updateYear);
|
|
1214
1217
|
this.addReaction(this.drawData);
|
|
@@ -1229,6 +1232,41 @@
|
|
|
1229
1232
|
//this.redrawData();
|
|
1230
1233
|
}
|
|
1231
1234
|
|
|
1235
|
+
updateColorPatterns() {
|
|
1236
|
+
if (this.MDL.color.scale.isPattern) {
|
|
1237
|
+
const colorConcept = this.MDL.color.data.concept;
|
|
1238
|
+
this.DOM.defs.selectAll(".flag")
|
|
1239
|
+
.data(this.MDL.color.data.domainData, d => d[0])
|
|
1240
|
+
.enter()
|
|
1241
|
+
.append("pattern")
|
|
1242
|
+
.attr("id", d => `flag-${d[0]}-${this.id}`)
|
|
1243
|
+
.attr("class", "flag")
|
|
1244
|
+
.attr("width", "100%")
|
|
1245
|
+
.attr("height", "100%")
|
|
1246
|
+
.attr("patternContentUnits", "objectBoundingBox")
|
|
1247
|
+
.html(d => d[1][colorConcept])
|
|
1248
|
+
.each(function() {
|
|
1249
|
+
const svg = d3.select(this).select("svg");
|
|
1250
|
+
if (svg.empty()) return;
|
|
1251
|
+
|
|
1252
|
+
if (!svg.attr("viewBox"))
|
|
1253
|
+
svg.attr("viewBox", `0 0 ${svg.attr("width")} ${svg.attr("height")}`);
|
|
1254
|
+
|
|
1255
|
+
// xMidYMid: center the image in the circle
|
|
1256
|
+
// slice: scale the image to fill the circle
|
|
1257
|
+
if (!svg.attr("preserveAspectRatio"))
|
|
1258
|
+
svg.attr("preserveAspectRatio", "xMidYMid slice");
|
|
1259
|
+
|
|
1260
|
+
svg.attr("width", 1).attr("height", 1);
|
|
1261
|
+
});
|
|
1262
|
+
// .attr("xlink:href", function(d) {
|
|
1263
|
+
// return "flags/" + d.CountryCode + ".svg";
|
|
1264
|
+
// });
|
|
1265
|
+
} else {
|
|
1266
|
+
this.DOM.defs.selectAll(".flag").remove();
|
|
1267
|
+
}
|
|
1268
|
+
}
|
|
1269
|
+
|
|
1232
1270
|
_updateShowYear() {
|
|
1233
1271
|
this.DOM.date.classed("vzb-hidden", !this.ui.timeInBackground);
|
|
1234
1272
|
}
|
|
@@ -1238,6 +1276,10 @@
|
|
|
1238
1276
|
this._date.setText(this.MDL.frame.value, duration);
|
|
1239
1277
|
}
|
|
1240
1278
|
|
|
1279
|
+
__getColor(key, valueC) {
|
|
1280
|
+
return valueC != null ? (this.MDL.color.scale.isPattern ? `url(#flag-${key}-${this.id})` : this.cScale(valueC)) : COLOR_WHITEISH;
|
|
1281
|
+
}
|
|
1282
|
+
|
|
1241
1283
|
_createAndDeleteBubbles() {
|
|
1242
1284
|
const _this = this;
|
|
1243
1285
|
const duration = this._getDuration();
|
|
@@ -1309,7 +1351,7 @@
|
|
|
1309
1351
|
d.r = VizabiSharedComponents.LegacyUtils.areaToRadius(_this.sScale(valueS || 0));
|
|
1310
1352
|
const scaledX = _this.xScale(valueX);
|
|
1311
1353
|
const scaledY = _this.yScale(valueY);
|
|
1312
|
-
const scaledC =
|
|
1354
|
+
const scaledC = _this.__getColor(d[Symbol.for(isTrail ? "trailHeadKey" : "key")], valueC);
|
|
1313
1355
|
|
|
1314
1356
|
if (!duration || !headTrail) {
|
|
1315
1357
|
circle
|
|
@@ -1339,10 +1381,10 @@
|
|
|
1339
1381
|
.attr("x1", scaledX)
|
|
1340
1382
|
.attr("y1", scaledY)
|
|
1341
1383
|
.attr("x2", scaledX0)
|
|
1342
|
-
.attr("y2", scaledY0)
|
|
1343
|
-
.style("stroke", scaledC)
|
|
1384
|
+
.attr("y2", scaledY0)
|
|
1344
1385
|
.attr("stroke-dasharray", Math.abs(scaledX - scaledX0) + Math.abs(scaledY - scaledY0))
|
|
1345
|
-
.attr("stroke-dashoffset", -d.r)
|
|
1386
|
+
.attr("stroke-dashoffset", -d.r)
|
|
1387
|
+
.style("stroke", _this.MDL.color.scale.isPattern ? null : scaledC);
|
|
1346
1388
|
}
|
|
1347
1389
|
}
|
|
1348
1390
|
|
|
@@ -1381,7 +1423,7 @@
|
|
|
1381
1423
|
//view.classed("vzb-hidden", d.hidden);
|
|
1382
1424
|
const scaledX = _this.xScale(valueX);
|
|
1383
1425
|
const scaledY = _this.yScale(valueY);
|
|
1384
|
-
const scaledC =
|
|
1426
|
+
const scaledC = _this.__getColor(d[Symbol.for(isTrail ? "trailHeadKey" : "key")], valueC);
|
|
1385
1427
|
|
|
1386
1428
|
if (!duration || !headTrail) {
|
|
1387
1429
|
const view = duration && !isTrail ?
|
|
@@ -1437,7 +1479,7 @@
|
|
|
1437
1479
|
}
|
|
1438
1480
|
|
|
1439
1481
|
trailLine
|
|
1440
|
-
.style("stroke", scaledC)
|
|
1482
|
+
.style("stroke", _this.MDL.color.scale.isPattern ? null : scaledC)
|
|
1441
1483
|
.attr("stroke-dasharray", Math.abs(scaledX - scaledX0) + Math.abs(scaledY - scaledY0))
|
|
1442
1484
|
.attr("stroke-dashoffset", -d.r);
|
|
1443
1485
|
}
|
|
@@ -1493,7 +1535,7 @@
|
|
|
1493
1535
|
d.r = VizabiSharedComponents.LegacyUtils.areaToRadius(_this.sScale(valueS || 0));
|
|
1494
1536
|
const scaledX = _this.xScale(valueX);
|
|
1495
1537
|
const scaledY = _this.yScale(valueY);
|
|
1496
|
-
const scaledC =
|
|
1538
|
+
const scaledC = _this.__getColor(d[Symbol.for(isTrail ? "trailHeadKey" : "key")], valueC);
|
|
1497
1539
|
|
|
1498
1540
|
const view = duration ?
|
|
1499
1541
|
d3.select(this)
|
|
@@ -1543,7 +1585,7 @@
|
|
|
1543
1585
|
.attr("y1", scaledY)
|
|
1544
1586
|
.attr("x2", scaledX0)
|
|
1545
1587
|
.attr("y2", scaledY0)
|
|
1546
|
-
.style("stroke", scaledC)
|
|
1588
|
+
.style("stroke", _this.MDL.color.scale.isPattern ? null : scaledC)
|
|
1547
1589
|
.attr("stroke-dasharray", Math.abs(scaledX - scaledX0) + Math.abs(scaledY - scaledY0))
|
|
1548
1590
|
.attr("stroke-dashoffset", -d.r);
|
|
1549
1591
|
}
|
|
@@ -1767,10 +1809,6 @@
|
|
|
1767
1809
|
const infoElHeight = this.profileConstants.infoElHeight;
|
|
1768
1810
|
const xAxisTitleBottomMargin = this.profileConstants.xAxisTitleBottomMargin;
|
|
1769
1811
|
|
|
1770
|
-
//labels
|
|
1771
|
-
this._labels.setCloseCrossHeight(_this.profileConstants.infoElHeight * 1.2);
|
|
1772
|
-
this._labels.setTooltipFontSize(_this.profileConstants.infoElHeight + "px");
|
|
1773
|
-
|
|
1774
1812
|
//stage
|
|
1775
1813
|
const height = this.height = (this.elementHeight - margin.top - margin.bottom) || 0;
|
|
1776
1814
|
const width = this.width = (this.elementWidth - margin.left * this.profileConstants.leftMarginRatio - margin.right) || 0;
|
|
@@ -2266,10 +2304,12 @@
|
|
|
2266
2304
|
if (highlightedFilter.markers.size === 1) {
|
|
2267
2305
|
const highlightedKey = highlightedFilter.markers.keys().next().value;
|
|
2268
2306
|
const d = Object.assign(this.model.dataMap.getByStr(highlightedKey));
|
|
2307
|
+
const selectedKey = d[Symbol.for("trailHeadKey")] || d[Symbol.for("key")];
|
|
2308
|
+
|
|
2269
2309
|
const x = _this.xScale(d[_this._alias("x")]);
|
|
2270
2310
|
const y = _this.yScale(d[_this._alias("y")]);
|
|
2271
2311
|
const s = d.r;
|
|
2272
|
-
const c =
|
|
2312
|
+
const c = _this.__getColor(selectedKey, d.color);
|
|
2273
2313
|
let entityOutOfView = false;
|
|
2274
2314
|
|
|
2275
2315
|
////const titles = _this._formatSTitleValues(values.size[utils.getKey(d, dataKeys.size)], values.color[utils.getKey(d, dataKeys.color)]);
|
|
@@ -2279,7 +2319,6 @@
|
|
|
2279
2319
|
}
|
|
2280
2320
|
|
|
2281
2321
|
//show tooltip
|
|
2282
|
-
const selectedKey = d[Symbol.for("trailHeadKey")] || d[Symbol.for("key")];
|
|
2283
2322
|
// const trailShow = this.MDL.trail.show;
|
|
2284
2323
|
// const trailStarts = this.MDL.trail.starts;
|
|
2285
2324
|
// const trailGroupDim = this.MDL.trail.groupDim;
|
|
@@ -2290,7 +2329,7 @@
|
|
|
2290
2329
|
let text = "";
|
|
2291
2330
|
|
|
2292
2331
|
text = isSelected ?
|
|
2293
|
-
!trailShow || isTailTrail || (!isTrail && !this.hoverBubble) ? "": this.localise(d
|
|
2332
|
+
!trailShow || isTailTrail || (!isTrail && !this.hoverBubble) ? "": this.localise(d[trailGroupDim])
|
|
2294
2333
|
:
|
|
2295
2334
|
this.__labelWithoutFrame(d);
|
|
2296
2335
|
|
|
@@ -2552,8 +2591,8 @@
|
|
|
2552
2591
|
placeholder: ".vzb-repeater",
|
|
2553
2592
|
model: marker,
|
|
2554
2593
|
options: {
|
|
2555
|
-
|
|
2556
|
-
|
|
2594
|
+
repeatedComponent: VizabiBubbleChart,
|
|
2595
|
+
repeatedComponentCssClass: "vzb-bubblechart"
|
|
2557
2596
|
},
|
|
2558
2597
|
name: "chart",
|
|
2559
2598
|
},{
|
|
@@ -2605,7 +2644,7 @@
|
|
|
2605
2644
|
}];
|
|
2606
2645
|
|
|
2607
2646
|
config.template = `
|
|
2608
|
-
<div class="vzb-repeater
|
|
2647
|
+
<div class="vzb-repeater"></div>
|
|
2609
2648
|
<div class="vzb-animationcontrols">
|
|
2610
2649
|
<div class="vzb-timeslider"></div>
|
|
2611
2650
|
<div class="vzb-speedslider"></div>
|
|
@@ -2684,7 +2723,7 @@
|
|
|
2684
2723
|
}
|
|
2685
2724
|
});
|
|
2686
2725
|
|
|
2687
|
-
BubbleChart.versionInfo = { version: "3.
|
|
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};
|
|
2688
2727
|
|
|
2689
2728
|
return BubbleChart;
|
|
2690
2729
|
|