Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,12 @@ test
dist/extras/mathjax

circle.yml
docker-compose.yml
bower.json

.ackrc
.agignore
.eslintignore
.eslintrc
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🍻


npm-debug.log
30 changes: 28 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<a href="https://plot.ly/javascript/"><img src="http://images.plot.ly/logo/[email protected]" height="70"></a>

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

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

Read the [Getting started page](https://plot.ly/javascript/getting-started/) for examples.
#### Webpack Usage

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`.

Read the [Getting started page](https://plot.ly/javascript/getting-started/) for more examples.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd put the Webpack Usage section below the Modules sections because a simple require('plotly.js') with webpack will grab the dist/ version so no need to worry about ify-loader in the simple case.


## Modules

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":

```javascript
// custom-plotly.js
var plotlyCore = require('plotly.js/lib/core');

// Load in the trace types for pie, and choropleth
plotlyCore.register([
require('plotly.js/lib/pie');
require('plotly.js/lib/choropleth');
]);

module.exports = customPlotly;
```
Then elsewhere in your code:

```javascript
var Plotly = require('./custom-plotly');
```

## Bugs and feature requests

Expand Down
9 changes: 9 additions & 0 deletions lib/bar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/**
* Copyright 2012-2016, Plotly, Inc.
* All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

module.exports = require('../src/traces/bar');
9 changes: 9 additions & 0 deletions lib/box.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/**
* Copyright 2012-2016, Plotly, Inc.
* All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

module.exports = require('../src/traces/box');
9 changes: 9 additions & 0 deletions lib/choropleth.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/**
* Copyright 2012-2016, Plotly, Inc.
* All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

module.exports = require('../src/traces/choropleth');
9 changes: 9 additions & 0 deletions lib/contour.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/**
* Copyright 2012-2016, Plotly, Inc.
* All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

module.exports = require('../src/traces/contour');
9 changes: 9 additions & 0 deletions lib/core.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/**
* Copyright 2012-2016, Plotly, Inc.
* All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

module.exports = require('../src/core');
9 changes: 9 additions & 0 deletions lib/heatmap.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/**
* Copyright 2012-2016, Plotly, Inc.
* All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

module.exports = require('../src/traces/heatmap');
9 changes: 9 additions & 0 deletions lib/histogram.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/**
* Copyright 2012-2016, Plotly, Inc.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mdtusz could you make the glob here grab the lib/ files too before we forget.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done here.

* All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

module.exports = require('../src/traces/histogram');
9 changes: 9 additions & 0 deletions lib/histogram2d.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/**
* Copyright 2012-2016, Plotly, Inc.
* All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

module.exports = require('../src/traces/histogram2d');
9 changes: 9 additions & 0 deletions lib/histogram2dcontour.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/**
* Copyright 2012-2016, Plotly, Inc.
* All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

module.exports = require('../src/traces/histogram2dcontour');
35 changes: 35 additions & 0 deletions lib/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/**
* Copyright 2012-2016, Plotly, Inc.
* All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

'use strict';

/*
* This file is browserify'ed into a standalone 'Plotly' object.
*/

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

// Load all trace modules
Core.register([
require('./bar'),
require('./box'),
require('./heatmap'),
require('./histogram'),
require('./histogram2d'),
require('./histogram2dcontour'),
require('./pie'),
require('./contour'),
require('./scatter3d'),
require('./surface'),
require('./mesh3d'),
require('./scattergeo'),
require('./choropleth'),
require('./scattergl')
]);

module.exports = Core;
9 changes: 9 additions & 0 deletions lib/mesh3d.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/**
* Copyright 2012-2016, Plotly, Inc.
* All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

module.exports = require('../src/traces/mesh3d');
9 changes: 9 additions & 0 deletions lib/pie.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/**
* Copyright 2012-2016, Plotly, Inc.
* All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

module.exports = require('../src/traces/pie');
9 changes: 9 additions & 0 deletions lib/scatter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/**
* Copyright 2012-2016, Plotly, Inc.
* All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

module.exports = require('../src/traces/scatter');
9 changes: 9 additions & 0 deletions lib/scatter3d.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/**
* Copyright 2012-2016, Plotly, Inc.
* All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

module.exports = require('../src/traces/scatter3d');
9 changes: 9 additions & 0 deletions lib/scattergeo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/**
* Copyright 2012-2016, Plotly, Inc.
* All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

module.exports = require('../src/traces/scattergeo');
9 changes: 9 additions & 0 deletions lib/scattergl.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/**
* Copyright 2012-2016, Plotly, Inc.
* All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

module.exports = require('../src/traces/scattergl');
9 changes: 9 additions & 0 deletions lib/surface.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/**
* Copyright 2012-2016, Plotly, Inc.
* All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

module.exports = require('../src/traces/surface');
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"version": "1.4.1",
"description": "The open source javascript graphing library that powers plotly",
"license": "MIT",
"main": "./src/index.js",
"webpack": "./dist/plotly.min.js",
"main": "./lib/index.js",
"webpack": "./dist/plotly.js",
"repository": {
"type": "git",
"url": "https://github.com/plotly/plotly.js.git"
Expand Down
21 changes: 1 addition & 20 deletions src/index.js → src/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@

/*
* Export the plotly.js API methods.
*
* This file is browserify'ed into a standalone 'Plotly' object.
*
*/

var Plotly = require('./plotly');
Expand All @@ -32,6 +29,7 @@ exports.addTraces = Plotly.addTraces;
exports.deleteTraces = Plotly.deleteTraces;
exports.moveTraces = Plotly.moveTraces;
exports.setPlotConfig = require('./plot_api/set_plot_config');
exports.register = Plotly.register;

// plot icons
exports.Icons = require('../build/ploticon');
Expand All @@ -45,20 +43,3 @@ exports.Queue = Plotly.Queue;

// export d3 used in the bundle
exports.d3 = require('d3');

Plotly.register([
require('./traces/bar'),
require('./traces/box'),
require('./traces/heatmap'),
require('./traces/histogram'),
require('./traces/histogram2d'),
require('./traces/histogram2dcontour'),
require('./traces/pie'),
require('./traces/contour'),
require('./traces/scatter3d'),
require('./traces/surface'),
require('./traces/mesh3d'),
require('./traces/scattergeo'),
require('./traces/choropleth'),
require('./traces/scattergl')
]);
2 changes: 1 addition & 1 deletion tasks/preprocess.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@ fs.copy(constants.pathToTopojsonSrc, constants.pathToTopojsonDist,
);

// inject package version into source index files
updateVersion(constants.pathToPlotlySrc);
updateVersion(constants.pathToPlotlyCore);
updateVersion(constants.pathToPlotlyGeoAssetsSrc);
5 changes: 4 additions & 1 deletion tasks/util/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ var pkg = require('../../package.json');

var pathToRoot = path.join(__dirname, '../../');
var pathToSrc = path.join(pathToRoot, 'src/');
var pathToLib = path.join(pathToRoot, 'lib/');
var pathToImageTest = path.join(pathToRoot, 'test/image');
var pathToDist = path.join(pathToRoot, 'dist/');
var pathToBuild = path.join(pathToRoot, 'build/');
Expand All @@ -17,8 +18,10 @@ var year = (new Date()).getFullYear();
module.exports = {
pathToRoot: pathToRoot,
pathToSrc: pathToSrc,
pathToLib: pathToLib,

pathToPlotlySrc: path.join(pathToSrc, 'index.js'),
pathToPlotlySrc: path.join(pathToLib, 'index.js'),
pathToPlotlyCore: path.join(pathToSrc, 'core.js'),
pathToPlotlyBuild: path.join(pathToBuild, 'plotly.js'),
pathToPlotlyDist: path.join(pathToDist, 'plotly.js'),
pathToPlotlyDistMin: path.join(pathToDist, 'plotly.min.js'),
Expand Down
1 change: 1 addition & 0 deletions tasks/util/shortcut_paths.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ var constants = require('./constants');

var shortcutsConfig = {
'@src': constants.pathToSrc,
'@lib': constants.pathToLib,
'@mocks': constants.pathToTestImageMocks
};

Expand Down
2 changes: 1 addition & 1 deletion test/jasmine/tests/click_test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var Plotly = require('@src/index');
var Plotly = require('@lib/index');
var Lib = require('@src/lib');

var createGraphDiv = require('../assets/create_graph_div');
Expand Down
2 changes: 1 addition & 1 deletion test/jasmine/tests/gl_plot_interact_test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
var d3 = require('d3');

var Plotly = require('@src/index');
var Plotly = require('@lib/index');

var createGraphDiv = require('../assets/create_graph_div');
var destroyGraphDiv = require('../assets/destroy_graph_div');
Expand Down
2 changes: 1 addition & 1 deletion test/jasmine/tests/hover_label_test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
var d3 = require('d3');

var Plotly = require('@src/index');
var Plotly = require('@lib/index');
var Fx = require('@src/plots/cartesian/graph_interact');
var Lib = require('@src/lib');

Expand Down
2 changes: 1 addition & 1 deletion test/jasmine/tests/hover_pie_test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var Plotly = require('@src/index');
var Plotly = require('@lib/index');
var Lib = require('@src/lib');

var createGraphDiv = require('../assets/create_graph_div');
Expand Down
2 changes: 1 addition & 1 deletion test/jasmine/tests/plot_api_test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var Plotly = require('@src');
var Plotly = require('@lib/index');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. We should test we expose to users. 🍻

var PlotlyInternal = require('@src/plotly');
var Plots = require('@src/plots/plots');
var Lib = require('@src/lib');
Expand Down
2 changes: 1 addition & 1 deletion test/jasmine/tests/plot_interact_test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
var d3 = require('d3');

var Plotly = require('@src/index');
var Plotly = require('@lib/index');

var createGraphDiv = require('../assets/create_graph_div');
var destroyGraphDiv = require('../assets/destroy_graph_div');
Expand Down