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

Constraint-type contours for regular contour (not on a carpet) #2270

Merged
merged 10 commits into from
Jan 30, 2018

Conversation

alexcjohnson
Copy link
Collaborator

Extends contours.type: 'constraint' to regular contour traces, not just contourcarpet.

cc @bpostlethwaite - lets not merge until we've waited a bit to see if we need a patch release, but you can use this branch for integration.

Copy link
Contributor

@etpinard etpinard left a comment

Choose a reason for hiding this comment

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

Solid PR 💪

I love the way contour and contourcarpet are getting to ♻️ much of their logic. I hope the upcoming contourgeo will be able to do the same.


One additional comment: why did the airfoil baseline change exactly?

'Sets the value or values by which to filter by.',

'Values are expected to be in the same type as the data linked',
'to *target*.',
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm. I think this was copied from transforms/filter.js, target makes no sense here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

good catch - 7c7a011

v1 = Math.min.apply(null, trace.contours.value);
v2 = Math.max.apply(null, trace.contours.value);
v1 = Math.min.apply(null, contours.value);
v2 = Math.max.apply(null, contours.value);
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't we use Lib.aggNums here in case contours.value has some non-numeric values?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

handleConstraintValueDefaults already cleans this up. Not sure if I actually agree with all the choices made there, but it doesn't look to me as though non-numeric values can get through.

}

var cd = heatmapCalc(gd, trace);
setContours(trace);
Copy link
Contributor

Choose a reason for hiding this comment

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

Lovely ♻️

var isNumeric = require('fast-isnumeric');
var COMPARISON_OPS2 = require('../../constants/filter_ops').COMPARISON_OPS2;
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like constraint_value_defaults.js is only required in constraint_defaults.js. Would you mind merging them in a single file?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ah yes, no need for separate files - 7e837ef

return heatmapHoverPoints(pointData, xval, yval, hovermode, hoverLayer, true);
var hoverData = heatmapHoverPoints(pointData, xval, yval, hovermode, hoverLayer, true);

if(hoverData) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like contourcarpet does not have a hoverPoints handler. Could it now reuse this one here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'm guessing it will take some work to sort out hover for contourcarpet. Unlike scattercarpet where you just have to look at the final position of each point, contourcarpet we would actually have to invert (x,y) back to (a,b), which I don't think has been implemented (it's in principle multi-valued anyway).


'use strict';

module.exports = {
Copy link
Contributor

Choose a reason for hiding this comment

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

❤️

var handleFillColorDefaults = require('../scatter/fillcolor_defaults');
var plotAttributes = require('../../plots/attributes');
var supplyConstraintDefaults = require('./constraint_value_defaults');
var addOpacity = require('../../components/color').addOpacity;

module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Much cleaner. Thanks!

});
}

return hoverData;
Copy link
Contributor

Choose a reason for hiding this comment

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

Moverover, should we show hover labels for x/y/z points outside the constraints? I'm not sure what's best here. Maybe that's why Ricky didn't bother implementing hover labels for contourcarpet in the first place.

Copy link
Contributor

Choose a reason for hiding this comment

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

One more comment: looks like contours would benefit from a version of hovermode: 'compare' that allows showing multiple labels of super-imposed traces as proposed in #720 (comment)

Currently, hovermode: 'closest' isn't that useful on the contour_constraints mock:

peek 2018-01-29 18-35

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Moverover, should we show hover labels for x/y/z points outside the constraints?

I think so. In fact it's possible that there actually aren't any data points (only interpolations) within the constraints, for [] type. Anyway I could see people using hover to see "how bad would it be to operate out here"

One more comment: looks like contours would benefit from a version of hovermode: 'compare' that allows showing multiple labels of super-imposed traces as proposed in #720 (comment)

Yes definitely - but perhaps we tackle that all at once as part of #720? There are going to be some weird cases with contours, like if two constraints overlay but with misaligned grids.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes definitely - but perhaps we tackle that all at once as part of #720?

Absolutely 👌

@alexcjohnson
Copy link
Collaborator Author

One additional comment: why did the airfoil baseline change exactly?

Because the streamlines and pressure contours weren't supposed to have legend entries at all, they're regular contours, not constraints. I suppose we could make it possible to give legend entries for contour plots with no colorscale, but that's not in scope here.

@etpinard
Copy link
Contributor

Looks great! Thanks for clarifying the airfoil diff. There's definitely room for making the hover behavior more configurable, but that can wait for (a) future PR(s).

💃

@alexcjohnson alexcjohnson merged commit a60cebf into master Jan 30, 2018
@alexcjohnson alexcjohnson deleted the contour-constraint branch January 30, 2018 20:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants