From 7c8d474b7f88ecde281cb0a517e5dfdade436052 Mon Sep 17 00:00:00 2001 From: Ben Postlethwaite Date: Mon, 28 Nov 2016 13:10:45 -0500 Subject: [PATCH 1/4] Update README.md --- README.md | 4 ---- 1 file changed, 4 deletions(-) diff --git a/README.md b/README.md index 1c74348..9e98bc5 100644 --- a/README.md +++ b/README.md @@ -3,10 +3,6 @@ > Analyze and Visualize Data, Together -If you have a question about streaming let us know or open an issue! - -`ben@plot.ly` && `alexandre@plot.ly` - ## Streaming Plot Examples - [mock sensor stream](http://plot.ly/~streaming-demos/6/) - [math bar fight](http://plot.ly/~streaming-demos/44/) From 4cdc9b79b3ea2879ba8a7cfaeb43bc7b89b27153 Mon Sep 17 00:00:00 2001 From: Jason Allan Date: Tue, 13 Jun 2017 12:03:21 +0100 Subject: [PATCH 2/4] Fixing Headings --- README.md | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 9e98bc5..5adea70 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -#Plotly Node API +# Plotly Node API [![Circle CI](https://circleci.com/gh/plotly/plotly-nodejs/tree/master.svg?style=svg)](https://circleci.com/gh/plotly/plotly-nodejs/tree/master) > Analyze and Visualize Data, Together @@ -7,12 +7,12 @@ - [mock sensor stream](http://plot.ly/~streaming-demos/6/) - [math bar fight](http://plot.ly/~streaming-demos/44/) -##Installation +## Installation ```javascript npm install plotly ``` -##Usage +## Usage ```javascript var plotly = require('plotly')('username','apiKey'); @@ -27,19 +27,19 @@ plotly.plot(data,graphOptions,function() { }); ``` -####Full REST API Documentation can be found here: [https://plot.ly/api/rest/](https://plot.ly/api/rest/) +#### Full REST API Documentation can be found here: [https://plot.ly/api/rest/](https://plot.ly/api/rest/) Sign up for plotly here: [https://plot.ly/](https://plot.ly/) and obtain your API key and Stream Tokens in your plotly settings: [https://plot.ly/settings](https://plot.ly/settings). -#Methods -##var plotly = require('plotly')(username, apiKey) +# Methods +## var plotly = require('plotly')(username, apiKey) `username` is a string containing your username `apiKey` is a string containing your API key ```javascript var plotly = require('plotly')('username', 'apiKey'); ``` -##plotly.plot(data,graphOptions[, callback]) +## plotly.plot(data,graphOptions[, callback]) Plotly graphs are described declaratively with a data JSON Object and a graphOptions JSON Object. `data` is an array of Objects and with each object containing data and styling information of separate graph traces. Docs: [https://plot.ly/api/rest](https://plot.ly/api/rest) `graphOptions` is an Object containing styling options like axis information and titles for your graph. Docs: [https://plot.ly/api/rest](https://plot.ly/api/rest) @@ -58,7 +58,7 @@ plotly.plot(data, graphOptions, function (err, msg) { console.log(msg); }); ``` -##var stream = plotly.stream(token[, callback]) +## var stream = plotly.stream(token[, callback]) `token` accepts a token string `callback(res)` where `res` is a the response object with the following attributes : `res.msg`, `res.statusCode` @@ -156,7 +156,7 @@ Plotly.plot(data, graphOptions, function (err, resp) { ``` -##plotly.getFigure(fileOwner, fileId[, callback]) +## plotly.getFigure(fileOwner, fileId[, callback]) `file_owner` accepts a string of the file owner's name `fileId` is an integer, representing the graph ID `callback(figure)` where `figure` is a the JSON object of the graph figure @@ -170,7 +170,7 @@ plotly.getFigure('fileOwner', 'fileId', function (err, figure) { }); ``` -##plotly.getImage(figure[, options, callback]) +## plotly.getImage(figure[, options, callback]) `figure` is a JSON object of the graph figure `options.format` | `jpg`, `png`, `pdf`, `eps`, `webp` `options.width` | width in `px` (default : 700) @@ -230,7 +230,7 @@ plotly.getFigure('fileOwner', 'fileId', function (err, figure) { }); ``` -##plotly.deletePlot(fid[, callback]) +## plotly.deletePlot(fid[, callback]) `fid` is a String, the id of the plot you wish you delete `callback` is a function with `err` and `plot` as parameters. `err`, if present, is the error message returned from the request. `plot` is the plot that was deleted. From 54c46f6eeb15f9c1eabad1e889bc8b7540534138 Mon Sep 17 00:00:00 2001 From: "pablo.mint" Date: Sun, 27 Aug 2017 11:47:10 -0300 Subject: [PATCH 3/4] Allow both jpg and jpeg as possible file formats I initially intended to simply correct the README, pointing out that the correct option is 'jpeg' and not 'jpg', but allowing both seems friendlier --- README.md | 2 +- index.js | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 5adea70..2474a53 100644 --- a/README.md +++ b/README.md @@ -172,7 +172,7 @@ plotly.getFigure('fileOwner', 'fileId', function (err, figure) { ## plotly.getImage(figure[, options, callback]) `figure` is a JSON object of the graph figure -`options.format` | `jpg`, `png`, `pdf`, `eps`, `webp` +`options.format` | `jpg`, `jpeg`, `png`, `pdf`, `eps`, `webp` `options.width` | width in `px` (default : 700) `options.height` | height in `px` (default : 500) diff --git a/index.js b/index.js index 01371e9..72719a6 100644 --- a/index.js +++ b/index.js @@ -207,6 +207,10 @@ Plotly.prototype.getImage = function (figure, opts, callback) { if (!figure) return new Error('no figure provided!'); var self = this; + + // allow both jpg and jpeg as file formats + if (opts && opts.format === 'jpg') opts.format = 'jpeg'; + var payload = JSON.stringify({ figure: figure, format: opts.format || 'png', From 9af6bf1af91cdddb4bf333b9ff9060f4493ab9e0 Mon Sep 17 00:00:00 2001 From: "pablo.mint" Date: Mon, 28 Aug 2017 22:09:07 -0300 Subject: [PATCH 4/4] Let getImage error when opts.format eq 'jpg' --- README.md | 2 +- index.js | 4 ---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/README.md b/README.md index 2474a53..855c846 100644 --- a/README.md +++ b/README.md @@ -172,7 +172,7 @@ plotly.getFigure('fileOwner', 'fileId', function (err, figure) { ## plotly.getImage(figure[, options, callback]) `figure` is a JSON object of the graph figure -`options.format` | `jpg`, `jpeg`, `png`, `pdf`, `eps`, `webp` +`options.format` | `jpeg`, `png`, `pdf`, `eps`, `webp` `options.width` | width in `px` (default : 700) `options.height` | height in `px` (default : 500) diff --git a/index.js b/index.js index 72719a6..01371e9 100644 --- a/index.js +++ b/index.js @@ -207,10 +207,6 @@ Plotly.prototype.getImage = function (figure, opts, callback) { if (!figure) return new Error('no figure provided!'); var self = this; - - // allow both jpg and jpeg as file formats - if (opts && opts.format === 'jpg') opts.format = 'jpeg'; - var payload = JSON.stringify({ figure: figure, format: opts.format || 'png',