https://github.com/mbejda/plotlychartexport
Export Plot.ly charts on the server
https://github.com/mbejda/plotlychartexport
chart charts nodejs plotly plotlyjs
Last synced: 6 months ago
JSON representation
Export Plot.ly charts on the server
- Host: GitHub
- URL: https://github.com/mbejda/plotlychartexport
- Owner: mbejda
- License: mit
- Created: 2017-12-13T23:33:54.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2017-12-15T11:40:50.000Z (about 8 years ago)
- Last Synced: 2025-05-11T11:16:19.966Z (8 months ago)
- Topics: chart, charts, nodejs, plotly, plotlyjs
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/plotlychartexport
- Size: 757 KB
- Stars: 8
- Watchers: 1
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README

# Plot.ly Chart Export
*PlotlyChartExport* uses Phantom.js to render plot.ly charts on the server. It crops the chart, base64 encodes it and returns the encoded chart in a resolving promise.
It does not rely on the filesystem nor does it rely on graphics libraries like `Cairo` making it an effective chart rendering solution for serverless environments.
- Only 1 Dependency
- Works in Serverless Environments
- Size < 10MB
### Installation
```
npm install plotlychartexport --save
```
### Usage
```javascript
/// include library
const exp = require('plotlychartexport');
/// define plot.ly data properties
let trace1 = {
x: [1, 2, 3, 4],
y: [10, 15, 13, 17],
type: 'scatter'
};
let trace2 = {
x: [1, 2, 3, 4],
y: [16, 5, 11, 9],
type: 'scatter'
};
/// define plot.ly layout
let layout = {
title: 'Line and Scatter Plot'
};
/// run render command
exp.render([trace1, trace2], layout).then((base) => {
console.log(base); /// base64
}, (error) => {
console.error(error);
})
```
## Create a Serverless Chart Export
Checkout this tutorial I made on how to create serverless chart exports on AWS to see the module in action.
[https://www.mbejda.com/creating-serverless-plotly-chart-exports](https://www.mbejda.com/creating-serverless-plotly-chart-exports/)
If you are experiencing any issues with this module open up a ticket and send me a tweet.
[@notMiloBejda](https://twitter.com/notMiloBejda)