Skip to content

Commit 38691f8

Browse files
committed
finishing touches
1 parent 5cae8a3 commit 38691f8

File tree

5 files changed

+32
-8
lines changed

5 files changed

+32
-8
lines changed

README.md

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<a href="https://plot.ly/javascript/"><img src="http://images.plot.ly/logo/plotlyjs-logo@2x.png" height="70"></a>
22

3-
[![npm version](https://badge.fury.io/js/plotly.js.svg)](https://badge.fury.io/js/plotly.js)
3+
[![npm version](https://badge.fury.io/js/plotly.js.svg)](https://badge.fury.io/js/plotly.js)
44
[![circle ci](https://circleci.com/gh/plotly/plotly.js.png?&style=shield&circle-token=1f42a03b242bd969756fc3e53ede204af9b507c0)](https://circleci.com/gh/plotly/plotly.js)
55

66
Built on top of [d3.js](http://d3js.org/) and [stack.gl](http://stack.gl/),
@@ -40,7 +40,33 @@ npm install plotly.js
4040
<script type="text/javascript" src="https://cdn.plot.ly/plotly-latest.min.js"></script>
4141
```
4242

43-
Read the [Getting started page](https://plot.ly/javascript/getting-started/) for examples.
43+
#### Webpack Usage
44+
45+
Plotly.js uses a browserify transform (glslify) to transform shaders. To make this work with Webpack, you will need to install [ify-loader]() and add it to your `webpack.config.json`.
46+
47+
Read the [Getting started page](https://plot.ly/javascript/getting-started/) for more examples.
48+
49+
## Modules
50+
51+
If you would like to reduce the bundle size of plotly.js, you can create a "custom" bundle by using `plotly.js/lib/core`, and loading only the trace types that you need (e.g. `pie` or `choropleth`). The recommended way to do this is by creating a "bundling file":
52+
53+
```javascript
54+
// custom-plotly.js
55+
var plotlyCore = require('plotly.js/lib/core');
56+
57+
// Load in the trace types for pie, and choropleth
58+
plotlyCore.register([
59+
require('plotly.js/lib/pie');
60+
require('plotly.js/lib/choropleth');
61+
]);
62+
63+
module.exports = customPlotly;
64+
```
65+
Then elsewhere in your code:
66+
67+
```javascript
68+
var Plotly = require('./custom-plotly');
69+
```
4470

4571
## Bugs and feature requests
4672

src/core.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414

1515
var Plotly = require('./plotly');
1616

17-
// export the version found in the package.json
18-
exports.version = require('../package.json').version;
17+
// package version injected by `npm run preprocess`
18+
exports.version = '1.4.1';
1919

2020
// plot api
2121
exports.plot = Plotly.plot;

src/index.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@
1414

1515
var Core = require('./core');
1616

17-
// package version injected by `npm run preprocess`
18-
exports.version = '1.4.1';
19-
2017
// Load all trace modules
2118
Core.register([
2219
require('./traces/bar'),

tasks/preprocess.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,5 @@ fs.copy(constants.pathToTopojsonSrc, constants.pathToTopojsonDist,
3131
);
3232

3333
// inject package version into source index files
34-
updateVersion(constants.pathToPlotlySrc);
34+
updateVersion(constants.pathToPlotlyCore);
3535
updateVersion(constants.pathToPlotlyGeoAssetsSrc);

tasks/util/constants.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ module.exports = {
1919
pathToSrc: pathToSrc,
2020

2121
pathToPlotlySrc: path.join(pathToSrc, 'index.js'),
22+
pathToPlotlyCore: path.join(pathToSrc, 'core.js'),
2223
pathToPlotlyBuild: path.join(pathToBuild, 'plotly.js'),
2324
pathToPlotlyDist: path.join(pathToDist, 'plotly.js'),
2425
pathToPlotlyDistMin: path.join(pathToDist, 'plotly.min.js'),

0 commit comments

Comments
 (0)