8000 Merge pull request #5 from plotly/save_icon_modebar · plotly/plotly.js@19886d2 · GitHub
[go: up one dir, main page]

Skip to content

Commit 19886d2

Browse files
committed
Merge pull request #5 from plotly/save_icon_modebar
add save and edit icon to modebar
2 parents c3c71e6 + 755bcf5 commit 19886d2

File tree

9 files changed

+54
-39
lines changed

9 files changed

+54
-39
lines changed

src/components/modebar/index.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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/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/plot_api/plot_config.js

Lines changed: 1 addition & 1 deletion
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,

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/plots.js

Lines changed: 34 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -342,37 +342,8 @@ function positionPlayWithData(gd, container){
342342
.text(gd._context.linkText + ' ' + String.fromCharCode(187));
343343

344344
if(gd._context.sendData) {
345-
link.on('click',function(){
346-
gd.emit('plotly_beforeexport');
347-
348-
var baseUrl = (window.PLOTLYENV && window.PLOTLYENV.BASE_URL) || 'https://plot.ly';
349-
350-
var hiddenformDiv = d3.select(gd)
351-
.append('div')
352-
.attr('id', 'hiddenform')
353-
.style('display', 'none');
354-
355-
var hiddenform = hiddenformDiv
356-
.append('form')
357-
.attr({
358-
action: baseUrl + '/external',
359-
method: 'post',
360-
target: '_blank'
361-
});
362-
363-
var hiddenformInput = hiddenform
364-
.append('input')
365-
.attr({
366-
type: 'text',
367-
name: 'data'
368-
});
369-
370-
hiddenformInput.node().value = plots.graphJson(gd, false, 'keepdata');
371-
hiddenform.node().submit();
372-
hiddenformDiv.remove();
373-
374-
gd.emit('plotly_afterexport');
375-
return false;
345+
link.on('click', function() {
346+
plots.sendDataToCloud(gd)
376347
});
377348
}
378349
else {
@@ -384,6 +355,38 @@ function positionPlayWithData(gd, container){
384355
});
385356
}
386357
}
358+
plots.sendDataToCloud = function(gd) {
359+
gd.emit('plotly_beforeexport');
360+
361+
var baseUrl = (window.PLOTLYENV && window.PLOTLYENV.BASE_URL) || 'https://plot.ly';
362+
363+
var hiddenformDiv = d3.select(gd)
364+
.append('div')
365+
.attr('id', 'hiddenform')
366+
.style('display', 'none');
367+
368+
var hiddenform = hiddenformDiv
369+
.append('form')
370+
.attr({
371+
action: baseUrl + '/external',
372+
method: 'post',
373+
target: '_blank'
374+
});
375+
376+
var hiddenformInput = hiddenform
377+
.append('input')
378+
.attr({
379+
type: 'text',
380+
name: 'data'
381+
});
382+
383+
hiddenformInput.node().value = plots.graphJson(gd, false, 'keepdata');
384+
hiddenform.node().submit();
385+
hiddenformDiv.remove();
386+
387+
gd.emit('plotly_afterexport');
388+
return false;
389+
}
387390

388391
plots.supplyDefaults = function(gd) {
389392
// fill in default values:

0 commit comments

Comments
 (0)
0