8000 Mention the full-json option in the Plotly.toImage warning by archmoj · Pull Request #5204 · plotly/plotly.js · GitHub
[go: up one dir, main page]

Skip to content
< 8000 h1 class="gh-header-title mb-2 lh-condensed f1 mr-0 flex-auto wb-break-word"> Mention the full-json option in the Plotly.toImage warning #5204
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 4 commits into from
Oct 14, 2020
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
8000
17 changes: 17 additions & 0 deletions src/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1244,3 +1244,20 @@ lib.ensureUniformFontSize = function(gd, baseFont) {
);
return out;
};

/**
* provide a human-readable lists with an optional ending separator such as A, B, C and D
*
* @param {array} arr : the array to join
* @param {string} mainSeparator : main separator
* @param {string} lastSeparator : optional last separator
*
* @return {string} : joined list
*/
lib.join2 = function(arr, mainSeparator, lastSeparator) {
var len = arr.length;
if(len > 2 && lastSeparator) {
return arr.slice(0, -1).join(mainSeparator) + lastSeparator + arr[len - 1];
}
return arr.join(mainSeparator);
};
2 changes: 1 addition & 1 deletion src/plot_api/to_image.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ function toImage(gd, opts) {
}

if(!isImpliedOrValid('format')) {
throw new Error('Image format is not jpeg, png, svg or webp.');
throw new Error('Export format is not ' + Lib.join2(attrs.format.values, ', ', ' or ') + '.');
}

var fullOpts = {};
Expand Down
2 changes: 1 addition & 1 deletion test/jasmine/tests/toimage_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ describe('Plotly.toImage', function() {
Plotly.plot(gd, fig.data, fig.layout)
.then(function(gd) {
expect(function() { Plotly.toImage(gd, {format: 'x'}); })
.toThrow(new Error('Image format is not jpeg, png, svg or webp.'));
.toThrow(new Error('Export format is not png, jpeg, webp, svg or full-json.'));
})
.catch(failTest)
.then(done);
Expand Down
0