Getting Started with Plotly in Nodejs
Plotly's Node.js graphing library makes interactive, publication-quality graphs online. Examples of how to make line plots, scatter plots, area charts, bar charts, error bars, box plots, histograms, heatmaps, subplots, multiple-axes, polar charts and bubble charts.
Getting started with Plotly for Nodejs
Installation
To install Plotly's Node module, use npm.
npm install plotly
Authentication
Fire up Node!
$ node
var plotly = require('plotly')("DemoAccount", "lr1c37zw81")
You'll need to replace "DemoAccount"
and "lr1c37zw81"
with your Plotly username and API key.
Special Instructions for Chart Studio Enterprise users
Your API key for account on the public cloud will be different than the API key in Chart Studio Enterprise. Visit https://plotly.your-company.com/settings/api/ to find your Chart Studio Enterprise API key. Remember to replace "your-company.com" with the URL of your Chart Studio Enterprise server.
Instantiate your plotly
object with the domain of your Chart Studio Enterprise server.
var plotly = require('plotly')({"username": "DemoAccount", "apiKey": "lr1c37zw81", "host": "plotly.your-company.com", "port": 443})
Remember to replace "your-company.com" with the URL of your Chart Studio Enterprise server. Questions? support@plot.ly
Start plotting!
Copy and paste the following to create your first graph using the Plotly Node library! If all goes well, the URL for your graph will be printed in your console.
var data = [{x:[0,1,2], y:[3,2,1], type: 'bar'}];
var layout = {fileopt : "overwrite", filename : "simple-node-example"};
plotly.plot(data, layout, function (err, msg) {
if (err) return console.log(err);
console.log(msg);
});