-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Modularise the library #41
Comments
+1. |
@eoinmurray thanks for writing in. We hope to achieve some sort of modularizibilty in the near future. I would be pretty easy to add a The main requirement for adding Down the road, I'm thinking (cc @alexcjohnson) of allowing users to make their own bundles using some sort of plugin signature e.g: var Plotly = require('plotly.js/lib/base');
require('plotly.js/lib/cartesian')(Plotly);
require('plotly.js/lib/scatter')(Plotly);
// and then maybe also modularizing non-trace components:
require('plotly.js/lib/errorbars')(Plotly);
require('plotly.js/lib/colorbar')(Plotly);
require('plotly.js/lib/legend')(Plotly)
// ... and a browserify step. That way users could include only the components and traces types they need. Achieving this would take some work cleaning up circular dependencies inside the src tree, but is definitively doable. Most things in the plotly.js src are already modules of their own. We just need to make a little more orthogonal to one another. |
+:100: for modularization/plugins (e.g. a download page that lets you pick and choose), we are considering using plot.ly and the biggest blocker is the size of the minified version. |
+1 for modularization so the large download can be avoided. @etpinard & @alexcjohnson - do you have a rough idea when you will be able to tackle this? Are you thinking days, weeks, or months? TIA |
It would be very nice to have d3 and the webgl stuff separate and optional. Having webgl stuff optional could help #22 . BTW, here is a map of the entire plotly.js dist file: http://bl.ocks.org/Hypercubed/e13c3ba8eb86ce0fc3ae |
apart from size issue there is and issue when you already have d3 loaded on page with some plugins. Loading plotly will rewrite d3 with plugins =( any big single-page app will face this issue while trying to use plotly |
@etpinard thx.. I'll consider switching to browserify =) |
For the first iteration: 1) Split library into a core lib module and trace-type lib modules Each trace module would register the appropriate plot-type module (e.g. the The core module would include all the cartesian plot code, all the components and the polar code for now. As it stands right now, the core module would be ~275 kb minified excluding d3. TODO:
var Plotly = require('plotly.js/lib/core');
var PlotlyScatter3D = require('plotly.js/lib/scatter3d'); // i.e. lib / <trace type>
Plotly.register(PlotlyGl3d); // or a better api?
Plotly.plot('graph', [ { type: 'scatter3d', x: [], y: [], z: [] } ]);
2) Register So that the users that already have var Plotly = require('plotly.js/lib/core');
Plotly.d3 = window.d3
// or something more sugary e.g.
Plotly.register({d3: window.d3}) TODO:
N.B. The dist bundles would still include |
re: (1), library modules
re: (2), d3 |
I'd prefer exposing the explicit: var Plotly = require('plotly.js/lib/core');
var PlotlyScatter3D = require('plotly.js/lib/scatter3d');
Plotly.register({traces: [PlotlyScatter3D]}); over the implicit: var Plotly = require('plotly.js/lib/core');
require('plotly.js/lib/scatter3d'); // where Plotly.Plots.register('scatter3d') would get called |
Ah I see, so the other args to the existing The call could even be |
@etpinard Just want to say I think this is a great plan. |
This issue is now part of https://github.com/plotly/plotly.js/milestones/Modular%20plotly.js . |
Hi all, PR #202 will bring modularity to plotly.js version 1.5.0. Feel free to comment on the PR. Note that |
👏 |
🎉 |
Plotly is a really great library, I think its the best js library out there for scientific graphs in javascript.
I wonder how difficult it is to modularise Plotly - as the current minified cdn version is 1.1MB.
This is quite heavy for someone who, for example, just wants to implement scatter plots.
I think the library would gain a lot of adoption if you could pick and choose which features to include into someonese project.
The text was updated successfully, but these errors were encountered: