Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
20 changes: 16 additions & 4 deletions types/plotly.js/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -292,15 +292,27 @@ export interface PlotlyHTMLElement extends HTMLElement {

export interface ToImgopts {
format: "jpeg" | "png" | "webp" | "svg";
width: number;
height: number;
/**
* If null, uses current graph width
*/
width: number | null;
/**
* If null, uses current graph height
*/
height: number | null;
scale?: number | undefined;
}

export interface DownloadImgopts {
format: "jpeg" | "png" | "webp" | "svg";
width: number;
height: number;
/**
* If null, uses current graph width
*/
width: number | null;
/**
* If null, uses current graph height
*/
height: number | null;
filename: string;
}

Expand Down
19 changes: 19 additions & 0 deletions types/plotly.js/test/core-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -714,6 +714,17 @@ function rand() {
})();
//////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////
// Plotly.toImage with null dimensions
(() => {
// Plotly.toImage will turn the plot in the given div into a data URL string
// toImage takes the div as the first argument and an object specifying image properties as the other
Plotly.toImage(graphDiv, { format: "png", width: null, height: null, scale: 2 }).then(dataUrl => {
// use the dataUrl
});
})();
//////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////
// Plotly.toImage + scale parameter
(() => {
Expand Down Expand Up @@ -744,6 +755,14 @@ function rand() {
})();
//////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////
// Plotly.downloadImage with null dimensions
(() => {
// downloadImage will accept the div as the first argument and an object specifying image properties as the other
Plotly.downloadImage(graphDiv, { format: "png", width: null, height: null, filename: "newplot" });
})();
//////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////
// Plotly.addFrames + Plotly.deleteFrames as per https://plot.ly/javascript/animations/
(() => {
Expand Down