Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose trace modules #202

Merged
merged 16 commits into from
Jan 21, 2016
Merged

Expose trace modules #202

merged 16 commits into from
Jan 21, 2016

Conversation

mdtusz
Copy link
Contributor

@mdtusz mdtusz commented Jan 20, 2016

The trace modules now can all be registered using Plotly.register and require('plotly.js/lib/<TRACE_TYPE>');.

I've added a brief change to the readme, but we will need to add more detailed documentation on the main docs site as well.

The one issue that will remain here is the requirement for users to add

<script src="mybundle.js" charset="utf-8">

to their code to avoid errors with special characters used in d3.

@mdtusz
Copy link
Contributor Author

mdtusz commented Jan 20, 2016

We likely should add some tests for making sure the trace modules remain independent from one another. I'm not sure of a better way to do this other than to just have tests using custom bundles with a single trace, and testing accordingly.

@etpinard
Copy link
Contributor

pinging @bpostlethwaite @alexcjohnson @cldougl @cpsievert @alexander-daniel

This is a very important PR.

@etpinard etpinard added this to the Modular plotly.js milestone Jan 20, 2016
@etpinard etpinard mentioned this pull request Jan 20, 2016
@@ -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. 🍻

@bpostlethwaite
Copy link
Member

outta the park! ⚾

💃

- add modules to TOC
- add info about version cdn URL
- generalize path to `custom-plotly.js`
- add info about cwise transform
@mdtusz
Copy link
Contributor Author

mdtusz commented Jan 21, 2016

Good additions to the README @etpinard .

mdtusz added a commit that referenced this pull request Jan 21, 2016
@mdtusz mdtusz merged commit 313fd91 into master Jan 21, 2016
@mdtusz mdtusz deleted the expose-trace-modules branch January 21, 2016 21:42
@aleburato
Copy link
Contributor

Hi guys. Thanks for the wonderful work. Please forgive my lack of experience with the build tools, but I can't wrap my head around this apparently simple process.

  • Goal: produce a minified custom plotly bundle with only bar, scatter and pie plots in it.

I have forked Plotly.js and checked out the sources,
If I run "npm run start-test_dashboard" everything builds fine and the fully-fledged Plotly.js is produced.
If I make any change to the plotly.js file, the watcher picks up the change and rebuilds it. So far, so good.

Question:

  • Where should I put my custom-plotly.js bundle file and how should I build it to get the stripped down version? If I try to run

npm run-script bundle

it always builds the standard plotly.js "fully-fledged" bundle.

Again, sorry for my lack of experience in the field. Any help is greatly appreciated.

Alessandro

@mdtusz
Copy link
Contributor Author

mdtusz commented Feb 3, 2016

Hi Allesandro,

To create your own bundle, you'll need to be making your own custom version within your own project. Ideally, you can make a new file somewhere in your own source directory, and inside it:

// Load in the plotly core (named custom here because 
// it's going to be our own custom build
var customPlotly = require('plotly.js/lib/core');

// load the traces you need
var pie = require('plotly.js/lib/pie');

// register the traces
customPlotly.register([pie]);

// export your custom plotly
module.exports = customPlotly;

Then, wherever you need to use plotly, you would use:

var Plotly = require ('PATH_TO_YOUR_CUSTOM_PLOTLY_FILE');

Bear in mind that with this method, you still will need to use browserify or webpack to resolve the require calls and bundle the code together.

Hope that helps!

@aleburato
Copy link
Contributor

Thanks! Yes, I read that, but i was assuming that there was something like:

npm run-script bundle my-custom-plotly

as

npm run-script bundle
only operates on the standard ploty.js

@mdtusz
Copy link
Contributor Author

mdtusz commented Feb 3, 2016

Correct. There was discussion of a built-in tool for creating custom bundles, but ultimately we decided it best to leave the task to the end user - all the npm scripts included in plotly.js are for internal development use.

@aleburato
Copy link
Contributor

Oh, I see. Thanks, I'll see what I can do starting from the internal scripts. It's all very new to me.

Again, congrats for the tremendous job you did with Plotly.

@rm-rf-etc
Copy link

@mdtusz, thanks for the example. Is something like this possible for people using react-plotly.js?

@alexcjohnson
Copy link
Collaborator

@rm-rf-etc yes, see https://github.com/plotly/react-plotly.js#customizing-the-plotlyjs-bundle

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants