Skip to content

Commit b0ae7f8

Browse files
committed
Merge branch 'master' into event-drag
2 parents 12658db + 6e2da35 commit b0ae7f8

File tree

125 files changed

+9941
-339
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

125 files changed

+9941
-339
lines changed

Diff for: dist/topojson/africa_110m.json

+1-1
Large diffs are not rendered by default.

Diff for: dist/topojson/africa_50m.json

+1-1
Large diffs are not rendered by default.

Diff for: dist/topojson/asia_110m.json

+1-1
Large diffs are not rendered by default.

Diff for: dist/topojson/asia_50m.json

+1-1
Large diffs are not rendered by default.

Diff for: dist/topojson/europe_110m.json

+1-1
Large diffs are not rendered by default.

Diff for: dist/topojson/europe_50m.json

+1-1
Large diffs are not rendered by default.

Diff for: dist/topojson/north-america_110m.json

+1-1
Large diffs are not rendered by default.

Diff for: dist/topojson/north-america_50m.json

+1-1
Large diffs are not rendered by default.

Diff for: dist/topojson/south-america_110m.json

+1-1
Large diffs are not rendered by default.

Diff for: dist/topojson/south-america_50m.json

+1-1
Large diffs are not rendered by default.

Diff for: dist/topojson/usa_110m.json

+1-1
Large diffs are not rendered by default.

Diff for: dist/topojson/usa_50m.json

+1-1
Large diffs are not rendered by default.

Diff for: dist/topojson/world_110m.json

+1-1
Large diffs are not rendered by default.

Diff for: dist/topojson/world_50m.json

+1-1
Large diffs are not rendered by default.

Diff for: lib/funnelarea.js

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/**
2+
* Copyright 2012-2019, Plotly, Inc.
3+
* All rights reserved.
4+
*
5+
* This source code is licensed under the MIT license found in the
6+
* LICENSE file in the root directory of this source tree.
7+
*/
8+
9+
'use strict';
10+
11+
module.exports = require('../src/traces/funnelarea');

Diff for: lib/index-finance.js

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Plotly.register([
1414
require('./bar'),
1515
require('./histogram'),
1616
require('./pie'),
17+
require('./funnelarea'),
1718
require('./ohlc'),
1819
require('./candlestick'),
1920
require('./funnel'),

Diff for: lib/index.js

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ Plotly.register([
2626

2727
require('./pie'),
2828
require('./sunburst'),
29+
require('./funnelarea'),
2930

3031
require('./scatter3d'),
3132
require('./surface'),

Diff for: package-lock.json

+6-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@
107107
"regl-splom": "^1.0.6",
108108
"right-now": "^1.0.0",
109109
"robust-orientation": "^1.1.3",
110-
"sane-topojson": "^2.0.0",
110+
"sane-topojson": "^3.0.1",
111111
"strongly-connected-components": "^1.0.1",
112112
"superscript-text": "^1.0.0",
113113
"svg-path-sdf": "^1.1.3",

Diff for: src/components/fx/calc.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ module.exports = function calc(gd) {
2828
// don't include hover calc fields for pie traces
2929
// as calcdata items might be sorted by value and
3030
// won't match the data array order.
31-
if(Registry.traceIs(trace, 'pie')) continue;
31+
if(Registry.traceIs(trace, 'pie-like')) continue;
3232

3333
var fillFn = Registry.traceIs(trace, '2dMap') ? paste : Lib.fillArray;
3434

Diff for: src/components/fx/hover.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1177,7 +1177,7 @@ function hoverAvoidOverlaps(hoverLabels, ax, fullLayout) {
11771177
donepositioning = true;
11781178
i = 0;
11791179
while(i < pointgroups.length - 1) {
1180-
// the higher (g0) and lower (g1) point group
1180+
// the higher (g0) and lower (g1) point group
11811181
var g0 = pointgroups[i];
11821182
var g1 = pointgroups[i + 1];
11831183

Diff for: src/components/legend/defaults.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
* LICENSE file in the root directory of this source tree.
77
*/
88

9-
109
'use strict';
1110

1211
var Registry = require('../../registry');
@@ -42,7 +41,7 @@ module.exports = function legendDefaults(layoutIn, layoutOut, fullData) {
4241
legendReallyHasATrace = true;
4342
// Always show the legend by default if there's a pie,
4443
// or if there's only one trace but it's explicitly shown
45-
if(Registry.traceIs(trace, 'pie') ||
44+
if(Registry.traceIs(trace, 'pie-like') ||
4645
trace._input.showlegend === true
4746
) {
4847
legendTraceCount++;

Diff for: src/components/legend/draw.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ module.exports = function draw(gd) {
5858
for(var j = 0; j < legendData[i].length; j++) {
5959
var item = legendData[i][j][0];
6060
var trace = item.trace;
61-
var isPie = Registry.traceIs(trace, 'pie');
62-
var name = isPie ? item.label : trace.name;
61+
var isPieLike = Registry.traceIs(trace, 'pie-like');
62+
var name = isPieLike ? item.label : trace.name;
6363
maxLength = Math.max(maxLength, name && name.length || 0);
6464
}
6565
}
@@ -110,7 +110,7 @@ module.exports = function draw(gd) {
110110

111111
traces.style('opacity', function(d) {
112112
var trace = d[0].trace;
113-
if(Registry.traceIs(trace, 'pie')) {
113+
if(Registry.traceIs(trace, 'pie-like')) {
114114
return hiddenSlices.indexOf(d[0].label) !== -1 ? 0.5 : 1;
115115
} else {
116116
return trace.visible === 'legendonly' ? 0.5 : 1;
@@ -375,7 +375,7 @@ function clickOrDoubleClick(gd, legend, legendItem, numClicks, evt) {
375375
if(trace._group) {
376376
evtData.group = trace._group;
377377
}
378-
if(trace.type === 'pie') {
378+
if(Registry.traceIs(trace, 'pie-like')) {
379379
evtData.label = legendItem.datum()[0].label;
380380
}
381381

@@ -399,11 +399,11 @@ function drawTexts(g, gd, maxLength) {
399399
var legendItem = g.data()[0][0];
400400
var fullLayout = gd._fullLayout;
401401
var trace = legendItem.trace;
402-
var isPie = Registry.traceIs(trace, 'pie');
402+
var isPieLike = Registry.traceIs(trace, 'pie-like');
403403
var traceIndex = trace.index;
404-
var isEditable = gd._context.edits.legendText && !isPie;
404+
var isEditable = gd._context.edits.legendText && !isPieLike;
405405

406-
var name = isPie ? legendItem.label : trace.name;
406+
var name = isPieLike ? legendItem.label : trace.name;
407407
if(trace._meta) {
408408
name = Lib.templateString(name, trace._meta);
409409
}

Diff for: src/components/legend/get_legend_data.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,11 @@
66
* LICENSE file in the root directory of this source tree.
77
*/
88

9-
109
'use strict';
1110

1211
var Registry = require('../../registry');
1312
var helpers = require('./helpers');
1413

15-
1614
module.exports = function getLegendData(calcdata, opts) {
1715
var lgroupToTraces = {};
1816
var lgroups = [];
@@ -45,7 +43,7 @@ module.exports = function getLegendData(calcdata, opts) {
4543

4644
if(!trace.visible || !trace.showlegend) continue;
4745

48-
if(Registry.traceIs(trace, 'pie')) {
46+
if(Registry.traceIs(trace, 'pie-like')) {
4947
if(!slicesShown[lgroup]) slicesShown[lgroup] = {};
5048

5149
for(j = 0; j < cd.length; j++) {

Diff for: src/components/legend/handle_click.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ module.exports = function handleClick(g, gd, numClicks) {
104104
}
105105
}
106106

107-
if(Registry.traceIs(fullTrace, 'pie')) {
107+
if(Registry.traceIs(fullTrace, 'pie-like')) {
108108
var thisLabel = legendItem.label;
109109
var thisLabelIndex = hiddenSlices.indexOf(thisLabel);
110110

Diff for: src/components/legend/style.js

+19-7
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ module.exports = function style(s, gd) {
8787
.each(styleFunnels)
8888
.each(styleBars)
8989
.each(styleBoxes)
90+
.each(styleFunnelareas)
9091
.each(stylePies)
9192
.each(styleLines)
9293
.each(stylePoints)
@@ -307,14 +308,14 @@ module.exports = function style(s, gd) {
307308
}
308309

309310
function styleBars(d) {
310-
styleBarFamily(d, this);
311+
styleBarLike(d, this);
311312
}
312313

313314
function styleFunnels(d) {
314-
styleBarFamily(d, this, 'funnel');
315+
styleBarLike(d, this, 'funnel');
315316
}
316317

317-
function styleBarFamily(d, lThis, desiredType) {
318+
function styleBarLike(d, lThis, desiredType) {
318319
var trace = d[0].trace;
319320
var marker = trace.marker || {};
320321
var markerLine = marker.line || {};
@@ -435,13 +436,24 @@ module.exports = function style(s, gd) {
435436
}
436437

437438
function stylePies(d) {
439+
stylePieLike(d, this, 'pie');
440+
}
441+
442+
function styleFunnelareas(d) {
443+
stylePieLike(d, this, 'funnelarea');
444+
}
445+
446+
function stylePieLike(d, lThis, desiredType) {
438447
var d0 = d[0];
439448
var trace = d0.trace;
440449

441-
var pts = d3.select(this).select('g.legendpoints')
442-
.selectAll('path.legendpie')
443-
.data(Registry.traceIs(trace, 'pie') && trace.visible ? [d] : []);
444-
pts.enter().append('path').classed('legendpie', true)
450+
var isVisible = (!desiredType) ? Registry.traceIs(trace, desiredType) :
451+
(trace.type === desiredType && trace.visible);
452+
453+
var pts = d3.select(lThis).select('g.legendpoints')
454+
.selectAll('path.legend' + desiredType)
455+
.data(isVisible ? [d] : []);
456+
pts.enter().append('path').classed('legend' + desiredType, true)
445457
.attr('d', 'M6,6H-6V-6H6Z')
446458
.attr('transform', 'translate(20,0)');
447459
pts.exit().remove();

Diff for: src/components/modebar/manage.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ function getButtonGroups(gd, buttonsToRemove, buttonsToAdd, showSendToCloud) {
8080
var hasGL3D = fullLayout._has('gl3d');
8181
var hasGeo = fullLayout._has('geo');
8282
var hasPie = fullLayout._has('pie');
83+
var hasFunnelarea = fullLayout._has('funnelarea');
8384
var hasGL2D = fullLayout._has('gl2d');
8485
var hasTernary = fullLayout._has('ternary');
8586
var hasMapbox = fullLayout._has('mapbox');
@@ -113,7 +114,7 @@ function getButtonGroups(gd, buttonsToRemove, buttonsToAdd, showSendToCloud) {
113114
var resetGroup = [];
114115
var dragModeGroup = [];
115116

116-
if((hasCartesian || hasGL2D || hasPie || hasTernary) + hasGeo + hasGL3D + hasMapbox + hasPolar > 1) {
117+
if((hasCartesian || hasGL2D || hasPie || hasFunnelarea || hasTernary) + hasGeo + hasGL3D + hasMapbox + hasPolar > 1) {
117118
// graphs with more than one plot types get 'union buttons'
118119
// which reset the view or toggle hover labels across all subplots.
119120
hoverGroup = ['toggleHover'];

Diff for: src/lib/geo_location_utils.js

+40-24
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,11 @@
66
* LICENSE file in the root directory of this source tree.
77
*/
88

9-
109
'use strict';
1110

1211
var countryRegex = require('country-regex');
1312
var Lib = require('../lib');
1413

15-
1614
// make list of all country iso3 ids from at runtime
1715
var countryIds = Object.keys(countryRegex);
1816

@@ -22,16 +20,48 @@ var locationmodeToIdFinder = {
2220
'country names': countryNameToISO3
2321
};
2422

25-
exports.locationToFeature = function(locationmode, location, features) {
23+
function countryNameToISO3(countryName) {
24+
for(var i = 0; i < countryIds.length; i++) {
25+
var iso3 = countryIds[i];
26+
var regex = new RegExp(countryRegex[iso3]);
27+
28+
if(regex.test(countryName.trim().toLowerCase())) return iso3;
29+
}
30+
31+
Lib.log('Unrecognized country name: ' + countryName + '.');
32+
33+
return false;
34+
}
35+
36+
function locationToFeature(locationmode, location, features) {
2637
if(!location || typeof location !== 'string') return false;
2738

28-
var locationId = getLocationId(locationmode, location);
39+
var locationId = locationmodeToIdFinder[locationmode](location);
40+
var filteredFeatures;
41+
var f, i;
2942

3043
if(locationId) {
31-
for(var i = 0; i < features.length; i++) {
32-
var feature = features[i];
44+
if(locationmode === 'USA-states') {
45+
// Filter out features out in USA
46+
//
47+
// This is important as the Natural Earth files
48+
// include state/provinces from USA, Canada, Australia and Brazil
49+
// which have some overlay in their two-letter ids. For example,
50+
// 'WA' is used for both Washington state and Western Australia.
51+
filteredFeatures = [];
52+
for(i = 0; i < features.length; i++) {
53+
f = features[i];
54+
if(f.properties && f.properties.gu && f.properties.gu === 'USA') {
55+
filteredFeatures.push(f);
56+
}
57+
}
58+
} else {
59+
filteredFeatures = features;
60+
}
3361

34-
if(feature.id === locationId) return feature;
62+
for(i = 0; i < filteredFeatures.length; i++) {
63+
f = filteredFeatures[i];
64+
if(f.id === locationId) return f;
3565
}
3666

3767
Lib.log([
@@ -41,22 +71,8 @@ exports.locationToFeature = function(locationmode, location, features) {
4171
}
4272

4373
return false;
44-
};
45-
46-
function getLocationId(locationmode, location) {
47-
var idFinder = locationmodeToIdFinder[locationmode];
48-
return idFinder(location);
4974
}
5075

51-
function countryNameToISO3(countryName) {
52-
for(var i = 0; i < countryIds.length; i++) {
53-
var iso3 = countryIds[i];
54-
var regex = new RegExp(countryRegex[iso3]);
55-
56-
if(regex.test(countryName.trim().toLowerCase())) return iso3;
57-
}
58-
59-
Lib.log('Unrecognized country name: ' + countryName + '.');
60-
61-
return false;
62-
}
76+
module.exports = {
77+
locationToFeature: locationToFeature
78+
};

Diff for: src/lib/index.js

+12
Original file line numberDiff line numberDiff line change
@@ -1159,3 +1159,15 @@ lib.fillText = function(calcPt, trace, contOut) {
11591159
lib.isValidTextValue = function(v) {
11601160
return v || v === 0;
11611161
};
1162+
1163+
lib.formatPercent = function(ratio, n) {
1164+
n = n || 0;
1165+
var str = (Math.round(100 * ratio * Math.pow(10, n)) * Math.pow(0.1, n)).toFixed(n) + '%';
1166+
for(var i = 0; i < n; i++) {
1167+
if(str.indexOf('.') !== -1) {
1168+
str = str.replace('0%', '%');
1169+
str = str.replace('.%', '%');
1170+
}
1171+
}
1172+
return str;
1173+
};

Diff for: src/plot_api/helpers.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
* LICENSE file in the root directory of this source tree.
77
*/
88

9-
109
'use strict';
1110

1211
var isNumeric = require('fast-isnumeric');
@@ -328,7 +327,7 @@ exports.cleanData = function(data) {
328327
trace.scene = Plots.subplotsRegistry.gl3d.cleanId(trace.scene);
329328
}
330329

331-
if(!traceIs(trace, 'pie') && !traceIs(trace, 'bar-like')) {
330+
if(!traceIs(trace, 'pie-like') && !traceIs(trace, 'bar-like')) {
332331
if(Array.isArray(trace.textposition)) {
333332
for(i = 0; i < trace.textposition.length; i++) {
334333
trace.textposition[i] = cleanTextPosition(trace.textposition[i]);

0 commit comments

Comments
 (0)