Skip to content
This repository was archived by the owner on Aug 29, 2025. It is now read-only.

Commit e74552f

Browse files
API example for getImage()
1 parent adc5ab5 commit e74552f

1 file changed

Lines changed: 13 additions & 6 deletions

File tree

‎examples/save_image.js‎

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,28 @@
11
'use strict';
22

3-
var plotly = require('../.')('username','api_key');
3+
var fs = require('fs');
4+
var plotly = require('../.')('alexander.daniel','yhs5fjlwin');
45

56
var trace1 = {
6-
x: [1, 2, 3, 4],
7-
y: [10, 15, 13, 17],
7+
x: [1, 2, 3, 4],
8+
y: [10, 15, 13, 17],
89
type: 'scatter'
910
};
1011

1112
var trace2 = {
12-
x: [1, 2, 3, 4],
13-
y: [16, 5, 11, 9],
13+
x: [1, 2, 3, 4],
14+
y: [16, 5, 11, 9],
1415
type: 'scatter'
1516
};
1617

1718
var figure = {
1819
'data': [trace1, trace2]
1920
};
2021

21-
plotly.saveImage(figure, 'img');
22+
var opts = {
23+
format: 'png'
24+
};
25+
26+
plotly.getImage(figure, opts, function (imageData) {
27+
fs.writeFile('1.png', imageData, 'base64');
28+
});

0 commit comments

Comments
 (0)