plotly.js 2.15.1 → 2.16.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/CHANGELOG.md +14 -0
- package/README.md +3 -3
- package/dist/README.md +19 -19
- package/dist/plot-schema.json +92 -0
- package/dist/plotly-basic.js +2 -2
- package/dist/plotly-basic.min.js +2 -2
- package/dist/plotly-cartesian.js +2 -2
- package/dist/plotly-cartesian.min.js +2 -2
- package/dist/plotly-finance.js +2 -2
- package/dist/plotly-finance.min.js +2 -2
- package/dist/plotly-geo-assets.js +2 -2
- package/dist/plotly-geo.js +2 -2
- package/dist/plotly-geo.min.js +2 -2
- package/dist/plotly-gl2d.js +2 -2
- package/dist/plotly-gl2d.min.js +2 -2
- package/dist/plotly-gl3d.js +2 -2
- package/dist/plotly-gl3d.min.js +2 -2
- package/dist/plotly-mapbox.js +240 -46
- package/dist/plotly-mapbox.min.js +3 -3
- package/dist/plotly-strict.js +240 -46
- package/dist/plotly-strict.min.js +11 -11
- package/dist/plotly-with-meta.js +273 -46
- package/dist/plotly.js +240 -46
- package/dist/plotly.min.js +2 -2
- package/package.json +4 -4
- package/src/plots/mapbox/layout_attributes.js +31 -0
- package/src/plots/mapbox/layout_defaults.js +13 -0
- package/src/plots/mapbox/mapbox.js +4 -0
- package/src/traces/choroplethmapbox/plot.js +3 -0
- package/src/traces/scattermapbox/attributes.js +45 -0
- package/src/traces/scattermapbox/convert.js +51 -6
- package/src/traces/scattermapbox/defaults.js +19 -0
- package/src/traces/scattermapbox/hover.js +10 -0
- package/src/traces/scattermapbox/plot.js +93 -36
- package/src/version.js +1 -1
package/dist/plotly-with-meta.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* plotly.js v2.
|
|
2
|
+
* plotly.js v2.16.1
|
|
3
3
|
* Copyright 2012-2022, Plotly, Inc.
|
|
4
4
|
* All rights reserved.
|
|
5
5
|
* Licensed under the MIT license
|
|
@@ -166252,6 +166252,37 @@ var attrs = module.exports = overrideAll({
|
|
|
166252
166252
|
].join(' ')
|
|
166253
166253
|
},
|
|
166254
166254
|
|
|
166255
|
+
bounds: {
|
|
166256
|
+
west: {
|
|
166257
|
+
valType: 'number',
|
|
166258
|
+
description: [
|
|
166259
|
+
'Sets the minimum longitude of the map (in degrees East)',
|
|
166260
|
+
'if `east`, `south` and `north` are declared.'
|
|
166261
|
+
].join(' ')
|
|
166262
|
+
},
|
|
166263
|
+
east: {
|
|
166264
|
+
valType: 'number',
|
|
166265
|
+
description: [
|
|
166266
|
+
'Sets the maximum longitude of the map (in degrees East)',
|
|
166267
|
+
'if `west`, `south` and `north` are declared.'
|
|
166268
|
+
].join(' ')
|
|
166269
|
+
},
|
|
166270
|
+
south: {
|
|
166271
|
+
valType: 'number',
|
|
166272
|
+
description: [
|
|
166273
|
+
'Sets the minimum latitude of the map (in degrees North)',
|
|
166274
|
+
'if `east`, `west` and `north` are declared.'
|
|
166275
|
+
].join(' ')
|
|
166276
|
+
},
|
|
166277
|
+
north: {
|
|
166278
|
+
valType: 'number',
|
|
166279
|
+
description: [
|
|
166280
|
+
'Sets the maximum latitude of the map (in degrees North)',
|
|
166281
|
+
'if `east`, `west` and `south` are declared.'
|
|
166282
|
+
].join(' ')
|
|
166283
|
+
}
|
|
166284
|
+
},
|
|
166285
|
+
|
|
166255
166286
|
layers: templatedArray('layer', {
|
|
166256
166287
|
visible: {
|
|
166257
166288
|
valType: 'boolean',
|
|
@@ -166501,6 +166532,19 @@ function handleDefaults(containerIn, containerOut, coerce, opts) {
|
|
|
166501
166532
|
coerce('bearing');
|
|
166502
166533
|
coerce('pitch');
|
|
166503
166534
|
|
|
166535
|
+
var west = coerce('bounds.west');
|
|
166536
|
+
var east = coerce('bounds.east');
|
|
166537
|
+
var south = coerce('bounds.south');
|
|
166538
|
+
var north = coerce('bounds.north');
|
|
166539
|
+
if(
|
|
166540
|
+
west === undefined ||
|
|
166541
|
+
east === undefined ||
|
|
166542
|
+
south === undefined ||
|
|
166543
|
+
north === undefined
|
|
166544
|
+
) {
|
|
166545
|
+
delete containerOut.bounds;
|
|
166546
|
+
}
|
|
166547
|
+
|
|
166504
166548
|
handleArrayContainerDefaults(containerIn, containerOut, {
|
|
166505
166549
|
name: 'layers',
|
|
166506
166550
|
handleItemDefaults: handleLayerDefaults
|
|
@@ -166666,6 +166710,9 @@ proto.createMap = function(calcData, fullLayout, resolve, reject) {
|
|
|
166666
166710
|
// store access token associated with this map
|
|
166667
166711
|
self.accessToken = opts.accesstoken;
|
|
166668
166712
|
|
|
166713
|
+
var bounds = opts.bounds;
|
|
166714
|
+
var maxBounds = bounds ? [[bounds.west, bounds.south], [bounds.east, bounds.north]] : null;
|
|
166715
|
+
|
|
166669
166716
|
// create the map!
|
|
166670
166717
|
var map = self.map = new mapboxgl.Map({
|
|
166671
166718
|
container: self.div,
|
|
@@ -166675,6 +166722,7 @@ proto.createMap = function(calcData, fullLayout, resolve, reject) {
|
|
|
166675
166722
|
zoom: opts.zoom,
|
|
166676
166723
|
bearing: opts.bearing,
|
|
166677
166724
|
pitch: opts.pitch,
|
|
166725
|
+
maxBounds: maxBounds,
|
|
166678
166726
|
|
|
166679
166727
|
interactive: !self.isStatic,
|
|
166680
166728
|
preserveDrawingBuffer: self.isStatic,
|
|
@@ -186743,6 +186791,9 @@ var proto = ChoroplethMapbox.prototype;
|
|
|
186743
186791
|
|
|
186744
186792
|
proto.update = function(calcTrace) {
|
|
186745
186793
|
this._update(convert(calcTrace));
|
|
186794
|
+
|
|
186795
|
+
// link ref for quick update during selections
|
|
186796
|
+
calcTrace[0].trace._glTrace = this;
|
|
186746
186797
|
};
|
|
186747
186798
|
|
|
186748
186799
|
proto.updateOnSelect = function(calcTrace) {
|
|
@@ -219582,6 +219633,7 @@ var colorScaleAttrs = _dereq_('../../components/colorscale/attributes');
|
|
|
219582
219633
|
|
|
219583
219634
|
var extendFlat = _dereq_('../../lib/extend').extendFlat;
|
|
219584
219635
|
var overrideAll = _dereq_('../../plot_api/edit_types').overrideAll;
|
|
219636
|
+
var mapboxLayoutAtributes = _dereq_('../../plots/mapbox/layout_attributes');
|
|
219585
219637
|
|
|
219586
219638
|
var lineAttrs = scatterGeoAttrs.line;
|
|
219587
219639
|
var markerAttrs = scatterGeoAttrs.marker;
|
|
@@ -219590,6 +219642,50 @@ module.exports = overrideAll({
|
|
|
219590
219642
|
lon: scatterGeoAttrs.lon,
|
|
219591
219643
|
lat: scatterGeoAttrs.lat,
|
|
219592
219644
|
|
|
219645
|
+
cluster: {
|
|
219646
|
+
enabled: {
|
|
219647
|
+
valType: 'boolean',
|
|
219648
|
+
description: 'Determines whether clustering is enabled or disabled.'
|
|
219649
|
+
},
|
|
219650
|
+
maxzoom: extendFlat({}, mapboxLayoutAtributes.layers.maxzoom, {
|
|
219651
|
+
description: [
|
|
219652
|
+
'Sets the maximum zoom level.',
|
|
219653
|
+
'At zoom levels equal to or greater than this, points will never be clustered.'
|
|
219654
|
+
].join(' ')
|
|
219655
|
+
}),
|
|
219656
|
+
step: {
|
|
219657
|
+
valType: 'number',
|
|
219658
|
+
arrayOk: true,
|
|
219659
|
+
dflt: -1,
|
|
219660
|
+
min: -1,
|
|
219661
|
+
description: [
|
|
219662
|
+
'Sets how many points it takes to create a cluster or advance to the next cluster step.',
|
|
219663
|
+
'Use this in conjunction with arrays for `size` and / or `color`.',
|
|
219664
|
+
'If an integer, steps start at multiples of this number.',
|
|
219665
|
+
'If an array, each step extends from the given value until one less than the next value.'
|
|
219666
|
+
].join(' ')
|
|
219667
|
+
},
|
|
219668
|
+
size: {
|
|
219669
|
+
valType: 'number',
|
|
219670
|
+
arrayOk: true,
|
|
219671
|
+
dflt: 20,
|
|
219672
|
+
min: 0,
|
|
219673
|
+
description: [
|
|
219674
|
+
'Sets the size for each cluster step.'
|
|
219675
|
+
].join(' ')
|
|
219676
|
+
},
|
|
219677
|
+
color: {
|
|
219678
|
+
valType: 'color',
|
|
219679
|
+
arrayOk: true,
|
|
219680
|
+
description: [
|
|
219681
|
+
'Sets the color for each cluster step.'
|
|
219682
|
+
].join(' ')
|
|
219683
|
+
},
|
|
219684
|
+
opacity: extendFlat({}, markerAttrs.opacity, {
|
|
219685
|
+
dflt: 1
|
|
219686
|
+
})
|
|
219687
|
+
},
|
|
219688
|
+
|
|
219593
219689
|
// locations
|
|
219594
219690
|
// locationmode
|
|
219595
219691
|
|
|
@@ -219736,11 +219832,12 @@ module.exports = function convert(gd, calcTrace) {
|
|
|
219736
219832
|
var hasText = subTypes.hasText(trace);
|
|
219737
219833
|
var hasCircles = (hasMarkers && trace.marker.symbol === 'circle');
|
|
219738
219834
|
var hasSymbols = (hasMarkers && trace.marker.symbol !== 'circle');
|
|
219835
|
+
var hasCluster = trace.cluster && trace.cluster.enabled;
|
|
219739
219836
|
|
|
219740
|
-
var fill = initContainer();
|
|
219741
|
-
var line = initContainer();
|
|
219742
|
-
var circle = initContainer();
|
|
219743
|
-
var symbol = initContainer();
|
|
219837
|
+
var fill = initContainer('fill');
|
|
219838
|
+
var line = initContainer('line');
|
|
219839
|
+
var circle = initContainer('circle');
|
|
219840
|
+
var symbol = initContainer('symbol');
|
|
219744
219841
|
|
|
219745
219842
|
var opts = {
|
|
219746
219843
|
fill: fill,
|
|
@@ -219784,6 +219881,29 @@ module.exports = function convert(gd, calcTrace) {
|
|
|
219784
219881
|
var circleOpts = makeCircleOpts(calcTrace);
|
|
219785
219882
|
circle.geojson = circleOpts.geojson;
|
|
219786
219883
|
circle.layout.visibility = 'visible';
|
|
219884
|
+
if(hasCluster) {
|
|
219885
|
+
circle.filter = ['!', ['has', 'point_count']];
|
|
219886
|
+
opts.cluster = {
|
|
219887
|
+
type: 'circle',
|
|
219888
|
+
filter: ['has', 'point_count'],
|
|
219889
|
+
layout: {visibility: 'visible'},
|
|
219890
|
+
paint: {
|
|
219891
|
+
'circle-color': arrayifyAttribute(trace.cluster.color, trace.cluster.step),
|
|
219892
|
+
'circle-radius': arrayifyAttribute(trace.cluster.size, trace.cluster.step),
|
|
219893
|
+
'circle-opacity': arrayifyAttribute(trace.cluster.opacity, trace.cluster.step),
|
|
219894
|
+
},
|
|
219895
|
+
};
|
|
219896
|
+
opts.clusterCount = {
|
|
219897
|
+
type: 'symbol',
|
|
219898
|
+
filter: ['has', 'point_count'],
|
|
219899
|
+
paint: {},
|
|
219900
|
+
layout: {
|
|
219901
|
+
'text-field': '{point_count_abbreviated}',
|
|
219902
|
+
'text-font': ['Open Sans Regular', 'Arial Unicode MS Regular'],
|
|
219903
|
+
'text-size': 12
|
|
219904
|
+
}
|
|
219905
|
+
};
|
|
219906
|
+
}
|
|
219787
219907
|
|
|
219788
219908
|
Lib.extendFlat(circle.paint, {
|
|
219789
219909
|
'circle-color': circleOpts.mcc,
|
|
@@ -219792,6 +219912,10 @@ module.exports = function convert(gd, calcTrace) {
|
|
|
219792
219912
|
});
|
|
219793
219913
|
}
|
|
219794
219914
|
|
|
219915
|
+
if(hasCircles && hasCluster) {
|
|
219916
|
+
circle.filter = ['!', ['has', 'point_count']];
|
|
219917
|
+
}
|
|
219918
|
+
|
|
219795
219919
|
if(hasSymbols || hasText) {
|
|
219796
219920
|
symbol.geojson = makeSymbolGeoJSON(calcTrace, gd);
|
|
219797
219921
|
|
|
@@ -219852,10 +219976,12 @@ module.exports = function convert(gd, calcTrace) {
|
|
|
219852
219976
|
return opts;
|
|
219853
219977
|
};
|
|
219854
219978
|
|
|
219855
|
-
function initContainer() {
|
|
219979
|
+
function initContainer(type) {
|
|
219856
219980
|
return {
|
|
219981
|
+
type: type,
|
|
219857
219982
|
geojson: geoJsonUtils.makeBlank(),
|
|
219858
219983
|
layout: { visibility: 'none' },
|
|
219984
|
+
filter: null,
|
|
219859
219985
|
paint: {}
|
|
219860
219986
|
};
|
|
219861
219987
|
}
|
|
@@ -219910,7 +220036,8 @@ function makeCircleOpts(calcTrace) {
|
|
|
219910
220036
|
|
|
219911
220037
|
features.push({
|
|
219912
220038
|
type: 'Feature',
|
|
219913
|
-
|
|
220039
|
+
id: i + 1,
|
|
220040
|
+
geometry: { type: 'Point', coordinates: lonlat },
|
|
219914
220041
|
properties: props
|
|
219915
220042
|
});
|
|
219916
220043
|
}
|
|
@@ -220034,6 +220161,20 @@ function isBADNUM(lonlat) {
|
|
|
220034
220161
|
return lonlat[0] === BADNUM;
|
|
220035
220162
|
}
|
|
220036
220163
|
|
|
220164
|
+
function arrayifyAttribute(values, step) {
|
|
220165
|
+
var newAttribute;
|
|
220166
|
+
if(Lib.isArrayOrTypedArray(values) && Lib.isArrayOrTypedArray(step)) {
|
|
220167
|
+
newAttribute = ['step', ['get', 'point_count'], values[0]];
|
|
220168
|
+
|
|
220169
|
+
for(var idx = 1; idx < values.length; idx++) {
|
|
220170
|
+
newAttribute.push(step[idx - 1], values[idx]);
|
|
220171
|
+
}
|
|
220172
|
+
} else {
|
|
220173
|
+
newAttribute = values;
|
|
220174
|
+
}
|
|
220175
|
+
return newAttribute;
|
|
220176
|
+
}
|
|
220177
|
+
|
|
220037
220178
|
},{"../../components/colorscale":379,"../../components/drawing":389,"../../components/fx/helpers":403,"../../constants/numerical":491,"../../lib":515,"../../lib/geojson_utils":509,"../../lib/svg_text_utils":541,"../../plots/mapbox/convert_text_opts":621,"../scatter/make_bubble_size_func":953,"../scatter/subtypes":961,"fast-isnumeric":190}],1004:[function(_dereq_,module,exports){
|
|
220038
220179
|
'use strict';
|
|
220039
220180
|
|
|
@@ -220051,6 +220192,10 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout
|
|
|
220051
220192
|
return Lib.coerce(traceIn, traceOut, attributes, attr, dflt);
|
|
220052
220193
|
}
|
|
220053
220194
|
|
|
220195
|
+
function coerce2(attr, dflt) {
|
|
220196
|
+
return Lib.coerce2(traceIn, traceOut, attributes, attr, dflt);
|
|
220197
|
+
}
|
|
220198
|
+
|
|
220054
220199
|
var len = handleLonLatDefaults(traceIn, traceOut, coerce);
|
|
220055
220200
|
if(!len) {
|
|
220056
220201
|
traceOut.visible = false;
|
|
@@ -220083,6 +220228,21 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout
|
|
|
220083
220228
|
}
|
|
220084
220229
|
}
|
|
220085
220230
|
|
|
220231
|
+
var clusterMaxzoom = coerce2('cluster.maxzoom');
|
|
220232
|
+
var clusterStep = coerce2('cluster.step');
|
|
220233
|
+
var clusterColor = coerce2('cluster.color', (traceOut.marker && traceOut.marker.color) || defaultColor);
|
|
220234
|
+
var clusterSize = coerce2('cluster.size');
|
|
220235
|
+
var clusterOpacity = coerce2('cluster.opacity');
|
|
220236
|
+
|
|
220237
|
+
var clusterEnabledDflt =
|
|
220238
|
+
clusterMaxzoom !== false ||
|
|
220239
|
+
clusterStep !== false ||
|
|
220240
|
+
clusterColor !== false ||
|
|
220241
|
+
clusterSize !== false ||
|
|
220242
|
+
clusterOpacity !== false;
|
|
220243
|
+
|
|
220244
|
+
coerce('cluster.enabled', clusterEnabledDflt);
|
|
220245
|
+
|
|
220086
220246
|
if(subTypes.hasText(traceOut)) {
|
|
220087
220247
|
handleTextDefaults(traceIn, traceOut, layout, coerce, {noSelect: true});
|
|
220088
220248
|
}
|
|
@@ -220141,6 +220301,7 @@ var Lib = _dereq_('../../lib');
|
|
|
220141
220301
|
var getTraceColor = _dereq_('../scatter/get_trace_color');
|
|
220142
220302
|
var fillText = Lib.fillText;
|
|
220143
220303
|
var BADNUM = _dereq_('../../constants/numerical').BADNUM;
|
|
220304
|
+
var LAYER_PREFIX = _dereq_('../../plots/mapbox/constants').traceLayerPrefix;
|
|
220144
220305
|
|
|
220145
220306
|
function hoverPoints(pointData, xval, yval) {
|
|
220146
220307
|
var cd = pointData.cd;
|
|
@@ -220148,6 +220309,14 @@ function hoverPoints(pointData, xval, yval) {
|
|
|
220148
220309
|
var xa = pointData.xa;
|
|
220149
220310
|
var ya = pointData.ya;
|
|
220150
220311
|
var subplot = pointData.subplot;
|
|
220312
|
+
var clusteredPointsIds = [];
|
|
220313
|
+
var layer = LAYER_PREFIX + trace.uid + '-circle';
|
|
220314
|
+
var hasCluster = trace.cluster && trace.cluster.enabled;
|
|
220315
|
+
|
|
220316
|
+
if(hasCluster) {
|
|
220317
|
+
var elems = subplot.map.queryRenderedFeatures(null, {layers: [layer]});
|
|
220318
|
+
clusteredPointsIds = elems.map(function(elem) {return elem.id;});
|
|
220319
|
+
}
|
|
220151
220320
|
|
|
220152
220321
|
// compute winding number about [-180, 180] globe
|
|
220153
220322
|
var winding = (xval >= 0) ?
|
|
@@ -220161,6 +220330,7 @@ function hoverPoints(pointData, xval, yval) {
|
|
|
220161
220330
|
function distFn(d) {
|
|
220162
220331
|
var lonlat = d.lonlat;
|
|
220163
220332
|
if(lonlat[0] === BADNUM) return Infinity;
|
|
220333
|
+
if(hasCluster && clusteredPointsIds.indexOf(d.i + 1) === -1) return Infinity;
|
|
220164
220334
|
|
|
220165
220335
|
var lon = Lib.modHalf(lonlat[0], 360);
|
|
220166
220336
|
var lat = lonlat[1];
|
|
@@ -220241,7 +220411,7 @@ module.exports = {
|
|
|
220241
220411
|
getExtraText: getExtraText
|
|
220242
220412
|
};
|
|
220243
220413
|
|
|
220244
|
-
},{"../../components/fx":407,"../../constants/numerical":491,"../../lib":515,"../scatter/get_trace_color":946}],1008:[function(_dereq_,module,exports){
|
|
220414
|
+
},{"../../components/fx":407,"../../constants/numerical":491,"../../lib":515,"../../plots/mapbox/constants":620,"../scatter/get_trace_color":946}],1008:[function(_dereq_,module,exports){
|
|
220245
220415
|
'use strict';
|
|
220246
220416
|
|
|
220247
220417
|
module.exports = {
|
|
@@ -220279,27 +220449,36 @@ module.exports = {
|
|
|
220279
220449
|
},{"../../plots/mapbox":622,"../scatter/marker_colorbar":954,"../scattergeo/calc":979,"./attributes":1002,"./defaults":1004,"./event_data":1005,"./format_labels":1006,"./hover":1007,"./plot":1009,"./select":1010}],1009:[function(_dereq_,module,exports){
|
|
220280
220450
|
'use strict';
|
|
220281
220451
|
|
|
220452
|
+
var Lib = _dereq_('../../lib');
|
|
220282
220453
|
var convert = _dereq_('./convert');
|
|
220283
220454
|
var LAYER_PREFIX = _dereq_('../../plots/mapbox/constants').traceLayerPrefix;
|
|
220284
|
-
var ORDER =
|
|
220455
|
+
var ORDER = {
|
|
220456
|
+
cluster: ['cluster', 'clusterCount', 'circle'],
|
|
220457
|
+
nonCluster: ['fill', 'line', 'circle', 'symbol'],
|
|
220458
|
+
};
|
|
220285
220459
|
|
|
220286
|
-
function ScatterMapbox(subplot, uid) {
|
|
220460
|
+
function ScatterMapbox(subplot, uid, clusterEnabled) {
|
|
220287
220461
|
this.type = 'scattermapbox';
|
|
220288
220462
|
this.subplot = subplot;
|
|
220289
220463
|
this.uid = uid;
|
|
220464
|
+
this.clusterEnabled = clusterEnabled;
|
|
220290
220465
|
|
|
220291
220466
|
this.sourceIds = {
|
|
220292
220467
|
fill: 'source-' + uid + '-fill',
|
|
220293
220468
|
line: 'source-' + uid + '-line',
|
|
220294
220469
|
circle: 'source-' + uid + '-circle',
|
|
220295
|
-
symbol: 'source-' + uid + '-symbol'
|
|
220470
|
+
symbol: 'source-' + uid + '-symbol',
|
|
220471
|
+
cluster: 'source-' + uid + '-circle',
|
|
220472
|
+
clusterCount: 'source-' + uid + '-circle',
|
|
220296
220473
|
};
|
|
220297
220474
|
|
|
220298
220475
|
this.layerIds = {
|
|
220299
220476
|
fill: LAYER_PREFIX + uid + '-fill',
|
|
220300
220477
|
line: LAYER_PREFIX + uid + '-line',
|
|
220301
220478
|
circle: LAYER_PREFIX + uid + '-circle',
|
|
220302
|
-
symbol: LAYER_PREFIX + uid + '-symbol'
|
|
220479
|
+
symbol: LAYER_PREFIX + uid + '-symbol',
|
|
220480
|
+
cluster: LAYER_PREFIX + uid + '-cluster',
|
|
220481
|
+
clusterCount: LAYER_PREFIX + uid + '-cluster-count',
|
|
220303
220482
|
};
|
|
220304
220483
|
|
|
220305
220484
|
// We could merge the 'fill' source with the 'line' source and
|
|
@@ -220313,11 +220492,20 @@ function ScatterMapbox(subplot, uid) {
|
|
|
220313
220492
|
|
|
220314
220493
|
var proto = ScatterMapbox.prototype;
|
|
220315
220494
|
|
|
220316
|
-
proto.addSource = function(k, opts) {
|
|
220317
|
-
|
|
220495
|
+
proto.addSource = function(k, opts, cluster) {
|
|
220496
|
+
var sourceOpts = {
|
|
220318
220497
|
type: 'geojson',
|
|
220319
|
-
data: opts.geojson
|
|
220320
|
-
}
|
|
220498
|
+
data: opts.geojson,
|
|
220499
|
+
};
|
|
220500
|
+
|
|
220501
|
+
if(cluster && cluster.enabled) {
|
|
220502
|
+
Lib.extendFlat(sourceOpts, {
|
|
220503
|
+
cluster: true,
|
|
220504
|
+
clusterMaxZoom: cluster.maxzoom,
|
|
220505
|
+
});
|
|
220506
|
+
}
|
|
220507
|
+
|
|
220508
|
+
this.subplot.map.addSource(this.sourceIds[k], sourceOpts);
|
|
220321
220509
|
};
|
|
220322
220510
|
|
|
220323
220511
|
proto.setSourceData = function(k, opts) {
|
|
@@ -220327,45 +220515,68 @@ proto.setSourceData = function(k, opts) {
|
|
|
220327
220515
|
};
|
|
220328
220516
|
|
|
220329
220517
|
proto.addLayer = function(k, opts, below) {
|
|
220330
|
-
|
|
220331
|
-
type:
|
|
220518
|
+
var source = {
|
|
220519
|
+
type: opts.type,
|
|
220332
220520
|
id: this.layerIds[k],
|
|
220333
220521
|
source: this.sourceIds[k],
|
|
220334
220522
|
layout: opts.layout,
|
|
220335
|
-
paint: opts.paint
|
|
220336
|
-
}
|
|
220523
|
+
paint: opts.paint,
|
|
220524
|
+
};
|
|
220525
|
+
if(opts.filter) {
|
|
220526
|
+
source.filter = opts.filter;
|
|
220527
|
+
}
|
|
220528
|
+
this.subplot.addLayer(source, below);
|
|
220337
220529
|
};
|
|
220338
220530
|
|
|
220339
220531
|
proto.update = function update(calcTrace) {
|
|
220532
|
+
var trace = calcTrace[0].trace;
|
|
220340
220533
|
var subplot = this.subplot;
|
|
220341
220534
|
var map = subplot.map;
|
|
220342
220535
|
var optsAll = convert(subplot.gd, calcTrace);
|
|
220343
220536
|
var below = subplot.belowLookup['trace-' + this.uid];
|
|
220344
220537
|
var i, k, opts;
|
|
220538
|
+
var hasCluster = !!(trace.cluster && trace.cluster.enabled);
|
|
220539
|
+
var hadCluster = !!this.clusterEnabled;
|
|
220345
220540
|
|
|
220346
220541
|
if(below !== this.below) {
|
|
220347
|
-
|
|
220348
|
-
|
|
220542
|
+
var order = ORDER.nonCluster;
|
|
220543
|
+
|
|
220544
|
+
for(i = order.length - 1; i >= 0; i--) {
|
|
220545
|
+
k = order[i];
|
|
220349
220546
|
map.removeLayer(this.layerIds[k]);
|
|
220350
220547
|
}
|
|
220351
|
-
for(i = 0; i <
|
|
220352
|
-
k =
|
|
220548
|
+
for(i = 0; i < order.length; i++) {
|
|
220549
|
+
k = order[i];
|
|
220353
220550
|
opts = optsAll[k];
|
|
220354
220551
|
this.addLayer(k, opts, below);
|
|
220355
220552
|
}
|
|
220356
220553
|
this.below = below;
|
|
220357
|
-
}
|
|
220358
|
-
|
|
220359
|
-
|
|
220360
|
-
|
|
220361
|
-
|
|
220362
|
-
|
|
220363
|
-
subplot.setOptions(this.layerIds[k], 'setLayoutProperty', opts.layout);
|
|
220364
|
-
|
|
220365
|
-
if(opts.layout.visibility === 'visible') {
|
|
220366
|
-
this.setSourceData(k, opts);
|
|
220367
|
-
subplot.setOptions(this.layerIds[k], 'setPaintProperty', opts.paint);
|
|
220554
|
+
} else if(hasCluster && !hadCluster) {
|
|
220555
|
+
for(i = ORDER.nonCluster.length - 1; i >= 0; i--) {
|
|
220556
|
+
k = ORDER.nonCluster[i];
|
|
220557
|
+
map.removeLayer(this.layerIds[k]);
|
|
220558
|
+
map.removeSource(this.sourceIds[k]);
|
|
220368
220559
|
}
|
|
220560
|
+
this.addSource('circle', optsAll.circle, trace.cluster);
|
|
220561
|
+
for(i = 0; i < ORDER.cluster.length; i++) {
|
|
220562
|
+
k = ORDER.cluster[i];
|
|
220563
|
+
opts = optsAll[k];
|
|
220564
|
+
this.addLayer(k, opts, below);
|
|
220565
|
+
}
|
|
220566
|
+
this.clusterEnabled = hasCluster;
|
|
220567
|
+
} else if(!hasCluster && hadCluster) {
|
|
220568
|
+
for(i = 0; i < ORDER.cluster.length; i++) {
|
|
220569
|
+
k = ORDER.cluster[i];
|
|
220570
|
+
map.removeLayer(this.layerIds[k]);
|
|
220571
|
+
}
|
|
220572
|
+
map.removeSource(this.sourceIds.circle);
|
|
220573
|
+
for(i = 0; i < ORDER.nonCluster.length; i++) {
|
|
220574
|
+
k = ORDER.nonCluster[i];
|
|
220575
|
+
opts = optsAll[k];
|
|
220576
|
+
this.addSource(k, opts, trace.cluster);
|
|
220577
|
+
this.addLayer(k, opts, below);
|
|
220578
|
+
}
|
|
220579
|
+
this.clusterEnabled = hasCluster;
|
|
220369
220580
|
}
|
|
220370
220581
|
|
|
220371
220582
|
// link ref for quick update during selections
|
|
@@ -220374,9 +220585,9 @@ proto.update = function update(calcTrace) {
|
|
|
220374
220585
|
|
|
220375
220586
|
proto.dispose = function dispose() {
|
|
220376
220587
|
var map = this.subplot.map;
|
|
220377
|
-
|
|
220378
|
-
for(var i =
|
|
220379
|
-
var k =
|
|
220588
|
+
var order = this.clusterEnabled ? ORDER.cluster : ORDER.nonCluster;
|
|
220589
|
+
for(var i = order.length - 1; i >= 0; i--) {
|
|
220590
|
+
var k = order[i];
|
|
220380
220591
|
map.removeLayer(this.layerIds[k]);
|
|
220381
220592
|
map.removeSource(this.sourceIds[k]);
|
|
220382
220593
|
}
|
|
@@ -220384,15 +220595,31 @@ proto.dispose = function dispose() {
|
|
|
220384
220595
|
|
|
220385
220596
|
module.exports = function createScatterMapbox(subplot, calcTrace) {
|
|
220386
220597
|
var trace = calcTrace[0].trace;
|
|
220387
|
-
var
|
|
220598
|
+
var hasCluster = trace.cluster && trace.cluster.enabled;
|
|
220599
|
+
var scatterMapbox = new ScatterMapbox(
|
|
220600
|
+
subplot,
|
|
220601
|
+
trace.uid,
|
|
220602
|
+
hasCluster
|
|
220603
|
+
);
|
|
220604
|
+
|
|
220388
220605
|
var optsAll = convert(subplot.gd, calcTrace);
|
|
220389
220606
|
var below = scatterMapbox.below = subplot.belowLookup['trace-' + trace.uid];
|
|
220607
|
+
var i, k, opts;
|
|
220390
220608
|
|
|
220391
|
-
|
|
220392
|
-
|
|
220393
|
-
|
|
220394
|
-
|
|
220395
|
-
|
|
220609
|
+
if(hasCluster) {
|
|
220610
|
+
scatterMapbox.addSource('circle', optsAll.circle, trace.cluster);
|
|
220611
|
+
for(i = 0; i < ORDER.cluster.length; i++) {
|
|
220612
|
+
k = ORDER.cluster[i];
|
|
220613
|
+
opts = optsAll[k];
|
|
220614
|
+
scatterMapbox.addLayer(k, opts, below);
|
|
220615
|
+
}
|
|
220616
|
+
} else {
|
|
220617
|
+
for(i = 0; i < ORDER.nonCluster.length; i++) {
|
|
220618
|
+
k = ORDER.nonCluster[i];
|
|
220619
|
+
opts = optsAll[k];
|
|
220620
|
+
scatterMapbox.addSource(k, opts, trace.cluster);
|
|
220621
|
+
scatterMapbox.addLayer(k, opts, below);
|
|
220622
|
+
}
|
|
220396
220623
|
}
|
|
220397
220624
|
|
|
220398
220625
|
// link ref for quick update during selections
|
|
@@ -220401,7 +220628,7 @@ module.exports = function createScatterMapbox(subplot, calcTrace) {
|
|
|
220401
220628
|
return scatterMapbox;
|
|
220402
220629
|
};
|
|
220403
220630
|
|
|
220404
|
-
},{"../../plots/mapbox/constants":620,"./convert":1003}],1010:[function(_dereq_,module,exports){
|
|
220631
|
+
},{"../../lib":515,"../../plots/mapbox/constants":620,"./convert":1003}],1010:[function(_dereq_,module,exports){
|
|
220405
220632
|
'use strict';
|
|
220406
220633
|
|
|
220407
220634
|
var Lib = _dereq_('../../lib');
|
|
@@ -233687,7 +233914,7 @@ function getSortFunc(opts, d2c) {
|
|
|
233687
233914
|
'use strict';
|
|
233688
233915
|
|
|
233689
233916
|
// package version injected by `npm run preprocess`
|
|
233690
|
-
exports.version = '2.
|
|
233917
|
+
exports.version = '2.16.1';
|
|
233691
233918
|
|
|
233692
233919
|
},{}],1133:[function(_dereq_,module,exports){
|
|
233693
233920
|
(function (global){(function (){
|