8000 add save and edit icon to modebar by cldougl · Pull Request #5 · plotly/plotly.js · GitHub
[go: up one dir, main page]

Skip to content

add save and edit icon to modebar #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Nov 16, 2015
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
add save and edit icon to modebar
  • Loading branch information
cldougl committed Nov 16, 2015
commit 79f3b67fa00e582cec7eb512a7716aae91684d20
10 changes: 10 additions & 0 deletions src/components/modebar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,11 @@ proto.toImage = function() {
});
};

proto.sendDataToCloud = function() {
var gd = this.graphInfo;
Plotly.Plots.sendDataToCloud(gd)
};

/**
*
* @Property config specification hash of button parameters
Expand Down Expand Up @@ -547,6 +552,11 @@ proto.config = function config() {
icon: 'camera',
click: this.toImage
},
sendDataToCloud: {
title: 'save and edit plot in cloud',
icon: 'disk',
click: this.sendDataToCloud
},
// gl3d
zoom3d: {
title: 'Zoom',
Expand Down
1 change: 1 addition & 0 deletions src/fonts/ploticon/_ploticon.scss
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,4 @@
.ploticon-3d_rotate:before { content: '\e80c'; } /* '' */
.ploticon-camera:before { content: '\e80d'; } /* '' */
.ploticon-movie:before { content: '\e80e'; } /* '' */
.ploticon-disk:before { content: '\e80f'; } /* '' */
Binary file modified src/fonts/ploticon/ploticon.eot
Binary file not shown.
7 changes: 4 additions & 3 deletions src/fonts/ploticon/ploticon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/fonts/ploticon/ploticon.ttf
Binary file not shown.
Binary file modified src/fonts/ploticon/ploticon.woff
Binary file not shown.
8 changes: 4 additions & 4 deletions src/plots/cartesian/graph_interact.js
Original file line number Diff line number Diff line change
Expand Up @@ -1319,15 +1319,15 @@ fx.modeBar = function(gd){
function chooseModebarButtons(fullLayout) {
if(fullLayout._hasGL3D) {
return [
['toImage'],
['toImage', 'sendDataToCloud'],
['orbitRotation', 'tableRotation', 'zoom3d', 'pan3d'],
['resetCameraDefault3d', 'resetCameraLastSave3d'],
['hoverClosest3d']
];
}
else if(fullLayout._hasGeo) {
return [
['toImage'],
['toImage', 'sendDataToCloud'],
['zoomInGeo', 'zoomOutGeo', 'resetGeo'],
['hoverClosestGeo']
];
Expand All @@ -1345,9 +1345,9 @@ function chooseModebarButtons(fullLayout) {
}
}

if(allFixed) buttons = [['toImage']];
if(allFixed) buttons = [['toImage', 'sendDataToCloud']];
else buttons = [
['toImage'],
['toImage', 'sendDataToCloud'],
['zoom2d', 'pan2d'],
['zoomIn2d', 'zoomOut2d', 'resetScale2d', 'autoScale2d']
];
Expand Down
66 changes: 35 additions & 31 deletions src/plots/plots.js
57AE
Original file line number Diff line number Diff line change
Expand Up @@ -336,43 +336,15 @@ function positionPlayWithData(gd, container){
var link = container.append('a')
.attr({
'xlink:xlink:href': '#',

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🐄 no new line

'class': 'link--impt link--embedview',
'font-weight':'bold'
})
.text(gd._context.linkText + ' ' + String.fromCharCode(187));

if(gd._context.sendData) {
link.on('click',function(){
gd.emit('plotly_beforeexport');

var baseUrl = (window.PLOTLYENV && window.PLOTLYENV.BASE_URL) || 'https://plot.ly';

var hiddenformDiv = d3.select(gd)
.append('div')
.attr('id', 'hiddenform')
.style('display', 'none');

var hiddenform = hiddenformDiv
.append('form')
.attr({
action: baseUrl + '/external',
method: 'post',
target: '_blank'
});

var hiddenformInput = hiddenform
.append('input')
.attr({
type: 'text',
name: 'data'
});

hiddenformInput.node().value = plots.graphJson(gd, false, 'keepdata');
hiddenform.node().submit();
hiddenformDiv.remove();

gd.emit('plotly_afterexport');
return false;
link.on('click', function(){
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🐄 some padding around function() {

plots.sendDataToCloud(gd)
});
}
else {
Expand All @@ -384,6 +356,38 @@ function positionPlayWithData(gd, container){
});
}
}
plots.sendDataToCloud = function(gd) {
gd.emit('plotly_beforeexport');

var baseUrl = (window.PLOTLYENV && window.PLOTLYENV.BASE_URL) || 'https://plot.ly';

var hiddenformDiv = d3.select(gd)
.append('div')
.attr('id', 'hiddenform')
.style('display', 'none');

var hiddenform = hiddenformDiv
.append('form')
.attr({
action: baseUrl + '/external',
method: 'post',
target: '_blank'
});

var hiddenformInput = hiddenform
.append('input')
.attr({
type: 'text',
name: 'data'
});

hiddenformInput.node().value = plots.graphJson(gd, false, 'keepdata');
hiddenform.node().submit();
hiddenformDiv.remove();

gd.emit('plotly_afterexport');
return false;
}

plots.supplyDefaults = function(gd) {
// fill in default values:
Expand Down
0