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

Trace type <-> trace module 1-to-1 correspondance #124

Merged
merged 28 commits into from Dec 17, 2015
Merged

Conversation

etpinard
Copy link
Contributor

@alexcjohnson @mdtusz @cldougl @bpostlethwaite

An important step towards modularity.

This PR:

  • adds two trace modules histogram2d and histogram2contour
  • registers histogram directly instead of passing through Bars
  • splits up the existing heatmap, bars, histogram and contour into a digestible one-file-per-step framework.
  • makes histogram, histogram2d, histogram2dcontour and contour have their own attribute object and defaults step instead of relying on composed module logic.

- the supply-defaults, calc, plot, style and hoverPoints steps
  each get a file of their own.
- helpers convertColumnXYZ, hasColumns and maxRowLength are now modules
  required into module files.
- colorbar and handleXYDefaults get their own files.
 - similar to scatter colorbar
- histogram2d and heatmap share the same calc function for now
- histogram2d and heatmap share the same supplyDefaults step
 - so that the new trace modules are registered via Plots.register
@etpinard etpinard added this to the Modular plotly.js milestone Dec 16, 2015

'use strict';

var heatmapHoverPoints = require('../heatmap/hover');
Copy link
Contributor Author

Choose a reason for hiding this comment

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

One example of the new pattern:

Here, a contour step requires-in only the part of heatmap it need.

This is important because, browserify bundles everything inside a required module i.e. it doesn't parse through it to check which parts of a module is used.

@etpinard
Copy link
Contributor Author

@alexcjohnson

If ok, I would rename the bars / Bars and boxes / Box modules to bar and box to make their name match their corresponding trace type.

@@ -25,7 +23,8 @@ var histogram = module.exports = {};
* constant and % work but they're not so meaningful. I guess it could be cool
* to allow quadrature combination of errors in summed histograms...
*/
Plotly.Plots.register(Plotly.Bars, 'histogram',

Plotly.Plots.register(exports, 'histogram',
Copy link
Contributor Author

Choose a reason for hiding this comment

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

in a future PR, these register calls will be moved out of the trace modules indices and into the root index.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

... as discussed in #41 (comment)

@alexcjohnson
Copy link
Contributor

@etpinard

I would rename the bars / Bars and boxes / Box modules to bar and box to make their name match their corresponding trace type.

Sure.

@alexcjohnson
Copy link
Contributor

I'm not going to be able to give this a full review, but overall the changes look great!

- split bar style defaults logic into own file to be reused
  by histogram defaults
- split histogram bin defaults logic into own file to be reused
  by histogram2d and histogram2dcontour defaults
- split up xyz heatmap defaults logic to be reused by contour defaults
- split up contour style defaults logic to be resued by
  histogram2d and histogram2dcontour
- split up histogram2d sample attr logic to be reused
  in histogram2dcontour defaults
- use contour style defaults in histogram2dcontour defaults
 - so that they export their own attributes and defaults
- check for 'area' trace type in get-plot-schema routine
  before calling traceIs()
if(autocontour) coerce('ncontours');
else coerce('contours.size');

handleStyleDefaults(traceIn, traceOut, coerce, layout);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@alexcjohnson no more Contour.supplyDefaults calling Heatmap.supplyDefaults.

The common part between the two in now in heatmap/xyz_defaults.js.

Copy link
Member

Choose a reason for hiding this comment

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

composition over inheritance - generally a good pattern :)

@cldougl
Copy link
Member

cldougl commented Dec 17, 2015

Looks good to me! ( 💃 as far as I'm concerned)

@etpinard
Copy link
Contributor Author

Ok. I'm going to merge this in.

The potential problem I'm most worried about is missing attributes/coerce statements for histogram, histogram2d, histogram2dcontour and contour leading to missing features in some currently un-tested attribute combinations.

We'll find out in v1.3.0.

etpinard added a commit that referenced this pull request Dec 17, 2015
Trace type <-> trace module 1-to-1 correspondance
@etpinard etpinard merged commit a7ab01b into master Dec 17, 2015
@etpinard etpinard deleted the trace-module-1-to-1 branch December 17, 2015 21:48
@etpinard etpinard mentioned this pull request Dec 22, 2015
etpinard added a commit that referenced this pull request Jun 30, 2016
- so that plotting code - which relies on marker.line.width to
  set the effective 'bargap' does not error out
- broken since #124
etpinard added a commit that referenced this pull request Jun 30, 2016
- so that plotting code - which relies on marker.line.width to
  set the effective 'bargap' does not error out
- broken since #124
@etpinard etpinard mentioned this pull request Jun 30, 2016
nielsenb-jf pushed a commit to nielsenb-jf/plotly.js that referenced this pull request Jul 20, 2016
- so that plotting code - which relies on marker.line.width to
  set the effective 'bargap' does not error out
- broken since plotly#124
etpinard added a commit that referenced this pull request Jul 21, 2016
- so that plotting code - which relies on marker.line.width to
  set the effective 'bargap' does not error out
- broken since #124
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.

None yet

5 participants