Skip to content

Commit f5ed930

Browse files
committed
Merge branch 'master' into image-test
2 parents 7352e87 + ae11cc0 commit f5ed930

Some content is hidden

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

49 files changed

+114405
-114663
lines changed

.gitignore

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,4 @@ node_modules
33
build/*
44
!build/README.md
55

6-
dist/*
7-
!dist/README.md
8-
96
npm-debug.log

devtools/test_dashboard/index.html

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,15 @@
1111

1212
<script type="text/javascript" src="../../dist/extras/mathjax/MathJax.js?config=TeX-AMS-MML_SVG"></script>
1313

14-
<script type="text/javascript" src="../../dist/plotly.js" charset="utf-8"></script>
15-
<script>PLOTLYENV = { TOPOJSON_URL: '../../src/assets/topojson/' };</script>
14+
<!-- use dev plotly.js build -->
15+
<script type="text/javascript" src="../../build/plotly.js" charset="utf-8"></script>
16+
17+
<!-- use local topojson files -->
18+
<script>Plotly.setPlotConfig({ topojsonURL: '../../dist/topojson/' });</script>
1619

1720
<script type="text/javascript" src="../../build/test_dashboard-bundle.js"></script>
1821

19-
<!-- helper functions to manipulate graph div -->
22+
<!-- helper functions to manipulate the graph div -->
2023
<script>
2124
var Tabs = {
2225
getGraph: function() {

dist/plotly-geo-assets.js

Lines changed: 42 additions & 34 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/plotly-with-meta.js

Lines changed: 58877 additions & 58461 deletions
Large diffs are not rendered by default.

dist/plotly.js

Lines changed: 55287 additions & 56028 deletions
Large diffs are not rendered by default.

dist/plotly.min.js

Lines changed: 35 additions & 36 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

src/assets/topojson/south-america_50m.json renamed to dist/topojson/south-america_50m.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.
File renamed without changes.

src/assets/topojson/usa_50m.json renamed to dist/topojson/usa_50m.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.
File renamed without changes.
File renamed without changes.

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
"delaunay-triangulate": "^1.1.6",
6666
"es6-promise": "^3.0.2",
6767
"fast-isnumeric": "^1.1.1",
68+
"fs-extra": "^0.26.2",
6869
"gl-error2d": "^1.0.0",
6970
"gl-error3d": "^1.0.0",
7071
"gl-line2d": "^1.2.1",
@@ -88,6 +89,7 @@
8889
"node-sass": "^3.4.1",
8990
"right-now": "^1.0.0",
9091
"robust-orientation": "^1.1.3",
92+
"sane-topojson": "^1.2.0",
9193
"superscript-text": "^1.0.0",
9294
"through2": "^2.0.0",
9395
"tinycolor2": "1.1.2",

src/assets/geo_assets.js

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,3 @@
1-
exports.topojsons = {};
1+
var saneTopojson = require('sane-topojson');
22

3-
exports.topojsons['world_110m'] = require('./topojson/world_110m.json');
4-
exports.topojsons['africa_110m'] = require('./topojson/africa_110m.json');
5-
exports.topojsons['asia_110m'] = require('./topojson/asia_110m.json');
6-
exports.topojsons['europe_110m'] = require('./topojson/europe_110m.json');
7-
exports.topojsons['north-america_110m'] = require('./topojson/north-america_110m.json');
8-
exports.topojsons['south-america_110m'] = require('./topojson/south-america_110m.json');
9-
exports.topojsons['usa_110m'] = require('./topojson/usa_110m');
10-
11-
exports.topojsons['world_50m'] = require('./topojson/world_50m.json');
12-
exports.topojsons['africa_50m'] = require('./topojson/africa_50m.json');
13-
exports.topojsons['asia_50m'] = require('./topojson/asia_50m.json');
14-
exports.topojsons['europe_50m'] = require('./topojson/europe_50m.json');
15-
exports.topojsons['north-america_50m'] = require('./topojson/north-america_50m.json');
16-
exports.topojsons['south-america_50m'] = require('./topojson/south-america_50m.json');
17-
exports.topojsons['usa_50m'] = require('./topojson/usa_50m.json');
3+
exports.topojson = saneTopojson;

src/components/modebar/index.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -450,14 +450,14 @@ proto.toImage = function() {
450450

451451
var ev = Plotly.Snapshot.toImage(this.graphInfo, {format: format});
452452

453-
var filename = this.graphInfo.fn || "newplot";
453+
var filename = this.graphInfo.fn || 'newplot';
454454
filename += '.' + format;
455455

456456
ev.once('success', function(result) {
457457

458458
_this._snapshotInProgress = false;
459459

460-
var downloadLink = document.createElement("a");
460+
var downloadLink = document.createElement('a');
461461
downloadLink.href = result;
462462
downloadLink.download = filename; // only supported by FF and Chrome
463463

@@ -478,6 +478,11 @@ proto.toImage = function() {
478478
});
479479
};
480480

481+
proto.sendDataToCloud = function() {
482+
var gd = this.graphInfo;
483+
Plotly.Plots.sendDataToCloud(gd)
484+
};
485+
481486
/**
482487
*
483488
* @Property config specification hash of button parameters
@@ -547,6 +552,11 @@ proto.config = function config() {
547552
icon: 'camera',
548553
click: this.toImage
549554
},
555+
sendDataToCloud: {
556+
title: 'save and edit plot in cloud',
557+
icon: 'disk',
558+
click: this.sendDataToCloud
559+
},
550560
// gl3d
551561
zoom3d: {
552562
title: 'Zoom',

src/css/_notifier.scss

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
11
.plotly-notifier {
2+
font-family: 'Open Sans'; // Because not all contexts have this specified.
23
position: fixed;
34
top: 50px;
45
right: 20px;
56
z-index: 10000;
7+
font-size: 10pt;
8+
max-width: 180px;
9+
10+
p {
11+
margin: 0;
12+
}
613

714
.notifier-note {
815
min-width: 180px;
@@ -37,5 +44,3 @@
3744
}
3845
}
3946
}
40-
41-

src/fonts/ploticon/_ploticon.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,4 @@
3939
.ploticon-3d_rotate:before { content: '\e80c'; } /* '' */
4040
.ploticon-camera:before { content: '\e80d'; } /* '' */
4141
.ploticon-movie:before { content: '\e80e'; } /* '' */
42+
.ploticon-disk:before { content: '\e80f'; } /* '' */

src/fonts/ploticon/ploticon.eot

228 Bytes
Binary file not shown.

src/fonts/ploticon/ploticon.svg

Lines changed: 4 additions & 3 deletions
Loading

src/fonts/ploticon/ploticon.ttf

228 Bytes
Binary file not shown.

src/fonts/ploticon/ploticon.woff

148 Bytes
Binary file not shown.

src/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ exports.Plots = Plotly.Plots;
2525
exports.Fx = Plotly.Fx;
2626
exports.Snapshot = Plotly.Snapshot;
2727
exports.PlotSchema = Plotly.PlotSchema;
28+
exports.Queue = Plotly.Queue;
2829

2930
// export d3 used in the bundle
3031
exports.d3 = require('d3');

src/lib/events.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
'use strict';
22

3+
/* global $:false */
4+
35
var EventEmitter = require('events').EventEmitter;
46

57
var Events = {

src/lib/topojson_utils.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,8 @@ topojsonUtils.getTopojsonName = function(geoLayout) {
1313
].join('');
1414
};
1515

16-
topojsonUtils.getTopojsonPath = function(topojsonName) {
17-
var topojsonUrl = (window.PLOTLYENV &&
18-
window.PLOTLYENV.TOPOJSON_URL) || './topojson/';
19-
20-
return topojsonUrl + topojsonName + '.json';
16+
topojsonUtils.getTopojsonPath = function(topojsonURL, topojsonName) {
17+
return topojsonURL + topojsonName + '.json';
2118
};
2219

2320
topojsonUtils.getTopojsonFeatures = function(trace, topojson) {

src/plot_api/plot_api.js

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -455,10 +455,10 @@ function plotGeo(gd) {
455455

456456
var i, geoId, fullGeoData, geo;
457457

458-
// if plotlyjs-geo-assets-bundle is not included,
459-
// initialize object to keep reference to every loaded topojsons
458+
// if 'plotly-geo-assets.js' is not included,
459+
// initialize object to keep reference to every loaded topojson
460460
if(window.PlotlyGeoAssets === undefined) {
461-
window.PlotlyGeoAssets = { topojsons : {} };
461+
window.PlotlyGeoAssets = { topojson : {} };
462462
}
463463

464464
for (i = 0; i < geoIds.length; i++) {
@@ -471,7 +471,8 @@ function plotGeo(gd) {
471471
geo = new Plotly.Geo(
472472
{
473473
id: geoId,
474-
container: fullLayout._geocontainer.node()
474+
container: fullLayout._geocontainer.node(),
475+
topojsonURL: gd._context.topojsonURL
475476
},
476477
fullLayout
477478
);
@@ -1358,7 +1359,9 @@ Plotly.extendTraces = function extendTraces (gd, update, indices, maxPoints) {
13581359
Plotly.redraw(gd);
13591360

13601361
var undoArgs = [gd, undo.update, indices, undo.maxPoints];
1361-
Plotly.Queue.add(gd, Plotly.prependTraces, undoArgs, extendTraces, arguments);
1362+
if (Plotly.Queue) {
1363+
Plotly.Queue.add(gd, Plotly.prependTraces, undoArgs, extendTraces, arguments);
1364+
}
13621365
};
13631366

13641367
Plotly.prependTraces = function prependTraces (gd, update, indices, maxPoints) {
@@ -1383,7 +1386,9 @@ Plotly.prependTraces = function prependTraces (gd, update, indices, maxPoints)
13831386
Plotly.redraw(gd);
13841387

13851388
var undoArgs = [gd, undo.update, indices, undo.maxPoints];
1386-
Plotly.Queue.add(gd, Plotly.extendTraces, undoArgs, prependTraces, arguments);
1389+
if (Plotly.Queue) {
1390+
Plotly.Queue.add(gd, Plotly.extendTraces, undoArgs, prependTraces, arguments);
1391+
}
13871392
};
13881393

13891394
/**
@@ -1427,7 +1432,7 @@ Plotly.addTraces = function addTraces (gd, traces, newIndices) {
14271432
// i.e., we can simply redraw and be done
14281433
if (typeof newIndices === 'undefined') {
14291434
Plotly.redraw(gd);
1430-
Plotly.Queue.add(gd, undoFunc, undoArgs, redoFunc, redoArgs);
1435+
if (Plotly.Queue) Plotly.Queue.add(gd, undoFunc, undoArgs, redoFunc, redoArgs);
14311436
return;
14321437
}
14331438

@@ -1450,10 +1455,10 @@ Plotly.addTraces = function addTraces (gd, traces, newIndices) {
14501455

14511456
// if we're here, the user has defined specific places to place the new traces
14521457
// this requires some extra work that moveTraces will do
1453-
Plotly.Queue.startSequence(gd);
1454-
Plotly.Queue.add(gd, undoFunc, undoArgs, redoFunc, redoArgs);
1458+
if (Plotly.Queue) Plotly.Queue.startSequence(gd);
1459+
if (Plotly.Queue) Plotly.Queue.add(gd, undoFunc, undoArgs, redoFunc, redoArgs);
14551460
Plotly.moveTraces(gd, currentIndices, newIndices);
1456-
Plotly.Queue.stopSequence(gd);
1461+
if (Plotly.Queue) Plotly.Queue.stopSequence(gd);
14571462
};
14581463

14591464
/**
@@ -1493,7 +1498,8 @@ Plotly.deleteTraces = function deleteTraces (gd, indices) {
14931498
}
14941499

14951500
Plotly.redraw(gd);
1496-
Plotly.Queue.add(gd, undoFunc, undoArgs, redoFunc, redoArgs);
1501+
1502+
if (Plotly.Queue) Plotly.Queue.add(gd, undoFunc, undoArgs, redoFunc, redoArgs);
14971503
};
14981504

14991505
/**
@@ -1587,8 +1593,10 @@ Plotly.moveTraces = function moveTraces (gd, currentIndices, newIndices) {
15871593
}
15881594

15891595
gd.data = newData;
1596+
15901597
Plotly.redraw(gd);
1591-
Plotly.Queue.add(gd, undoFunc, undoArgs, redoFunc, redoArgs);
1598+
1599+
if (Plotly.Queue) Plotly.Queue.add(gd, undoFunc, undoArgs, redoFunc, redoArgs);
15921600
};
15931601

15941602
// -----------------------------------------------------
@@ -2025,7 +2033,9 @@ Plotly.restyle = function restyle(gd, astr, val, traces) {
20252033

20262034
// now all attribute mods are done, as are redo and undo
20272035
// so we can save them
2028-
Plotly.Queue.add(gd, restyle, [gd, undoit, traces], restyle, [gd, redoit, traces]);
2036+
if(Plotly.Queue) {
2037+
Plotly.Queue.add(gd, restyle, [gd, undoit, traces], restyle, [gd, redoit, traces]);
2038+
}
20292039

20302040
// do we need to force a recalc?
20312041
var autorangeOn = false;
@@ -2403,7 +2413,9 @@ Plotly.relayout = function relayout(gd, astr, val) {
24032413
}
24042414
// now all attribute mods are done, as are
24052415
// redo and undo so we can save them
2406-
Plotly.Queue.add(gd, relayout, [gd, undoit], relayout, [gd, redoit]);
2416+
if(Plotly.Queue) {
2417+
Plotly.Queue.add(gd, relayout, [gd, undoit], relayout, [gd, redoit]);
2418+
}
24072419

24082420
// calculate autosizing - if size hasn't changed,
24092421
// will remove h&w so we don't need to redraw

src/plot_api/plot_config.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ module.exports = {
3535
showTips: true,
3636

3737
// link to open this plot in plotly
38-
showLink: true,
38+
showLink: false,
3939

4040
// if we show a link, does it contain data or just link to a plotly file?
4141
sendData: true,
@@ -57,7 +57,10 @@ module.exports = {
5757

5858
// function to add the background color to a different container
5959
// or 'opaque' to ensure there's white behind it
60-
setBackground: defaultSetBackground
60+
setBackground: defaultSetBackground,
61+
62+
// URL to topojson files used in geo charts
63+
topojsonURL: 'https://cdn.plot.ly/'
6164

6265
};
6366

src/plots/cartesian/graph_interact.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1319,15 +1319,15 @@ fx.modeBar = function(gd){
13191319
function chooseModebarButtons(fullLayout) {
13201320
if(fullLayout._hasGL3D) {
13211321
return [
1322-
['toImage'],
1322+
['toImage', 'sendDataToCloud'],
13231323
['orbitRotation', 'tableRotation', 'zoom3d', 'pan3d'],
13241324
['resetCameraDefault3d', 'resetCameraLastSave3d'],
13251325
['hoverClosest3d']
13261326
];
13271327
}
13281328
else if(fullLayout._hasGeo) {
13291329
return [
1330-
['toImage'],
1330+
['toImage', 'sendDataToCloud'],
13311331
['zoomInGeo', 'zoomOutGeo', 'resetGeo'],
13321332
['hoverClosestGeo']
13331333
];
@@ -1345,9 +1345,9 @@ function chooseModebarButtons(fullLayout) {
13451345
}
13461346
}
13471347

1348-
if(allFixed) buttons = [['toImage']];
1348+
if(allFixed) buttons = [['toImage', 'sendDataToCloud']];
13491349
else buttons = [
1350-
['toImage'],
1350+
['toImage', 'sendDataToCloud'],
13511351
['zoom2d', 'pan2d'],
13521352
['zoomIn2d', 'zoomOut2d', 'resetScale2d', 'autoScale2d']
13531353
];

src/plots/geo/geo.js

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ function Geo(options, fullLayout) {
2222

2323
this.id = options.id;
2424
this.container = options.container;
25+
this.topojsonURL = options.topojsonURL;
2526

2627
// add a few projection types to d3.geo,
2728
// a subset of https://github.com/d3/d3-geo-projection
@@ -73,27 +74,27 @@ proto.plot = function(geoData, fullLayout) {
7374

7475
_this.framework
7576
.call(_this.zoom)
76-
.on('dblclick', _this.zoomReset);
77-
78-
// N.B. the on 'dblclick doesn't in d3 3.5+
79-
// https://github.com/mbostock/d3/issues/1985
77+
.on('dblclick.zoom', _this.zoomReset);
8078

8179
topojsonNameNew = topojsonUtils.getTopojsonName(geoLayout);
8280

8381
if(_this.topojson===null || topojsonNameNew!==_this.topojsonName) {
8482
_this.topojsonName = topojsonNameNew;
8583

86-
if(PlotlyGeoAssets.topojsons[_this.topojsonName] !== undefined) {
87-
_this.topojson = PlotlyGeoAssets.topojsons[_this.topojsonName];
84+
if(PlotlyGeoAssets.topojson[_this.topojsonName] !== undefined) {
85+
_this.topojson = PlotlyGeoAssets.topojson[_this.topojsonName];
8886
_this.onceTopojsonIsLoaded(geoData, geoLayout);
8987
}
9088
else {
91-
topojsonPath = topojsonUtils.getTopojsonPath(_this.topojsonName);
89+
topojsonPath = topojsonUtils.getTopojsonPath(
90+
_this.topojsonURL,
91+
_this.topojsonName
92+
);
9293

9394
// N.B this is async
9495
d3.json(topojsonPath, function(error, topojson) {
9596
_this.topojson = topojson;
96-
PlotlyGeoAssets.topojsons[_this.topojsonName] = topojson;
97+
PlotlyGeoAssets.topojson[_this.topojsonName] = topojson;
9798
_this.onceTopojsonIsLoaded(geoData, geoLayout);
9899
});
99100
}

0 commit comments

Comments
 (0)