8000 Constraint-type contours for regular contour (not on a carpet) by alexcjohnson · Pull Request #2270 · plotly/plotly.js · GitHub
[go: up one dir, main page]

Skip to content

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

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

Merged
merged 10 commits into from
Jan 30, 2018
Prev Previous commit
Next Next commit
merge constraint_(value_)defaults
  • Loading branch information
alexcjohnson committed Jan 30, 2018
commit 7e837efd67cdd56c5934fbf92d4f8fbbd545c305
47 changes: 45 additions & 2 deletions src/traces/contour/constraint_defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,17 @@


'use strict';
var isNumeric = require('fast-isnumeric');

var handleConstraintValueDefaults = require('./constraint_value_defaults');
var handleLabelDefaults = require('./label_defaults');

var Color = require('../../components/color');
var addOpacity = Color.addOpacity;
var opacity = Color.opacity;
var CONSTRAINT_REDUCTION = require('../../constants/filter_ops').CONSTRAINT_REDUCTION;

var filterOps = require('../../constants/filter_ops');
var CONSTRAINT_REDUCTION = filterOps.CONSTRAINT_REDUCTION;
var COMPARISON_OPS2 = filterOps.COMPARISON_OPS2;

module.exports = function handleConstraintDefaults(traceIn, traceOut, coerce, layout, defaultColor, opts) {
var contours = traceOut.contours;
Expand Down Expand Up @@ -48,3 +52,42 @@ module.exports = function handleConstraintDefaults(traceIn, traceOut, coerce, la

handleLabelDefaults(coerce, layout, lineColor, opts);
};

function handleConstraintValueDefaults(coerce, contours) {
var zvalue;

if(COMPARISON_OPS2.indexOf(contours.operation) === -1) {
// Requires an array of two numbers:
coerce('contours.value', [0, 1]);

if(!Array.isArray(contours.value)) {
if(isNumeric(contours.value)) {
zvalue = parseFloat(contours.value);
contours.value = [zvalue, zvalue + 1];
}
} else if(contours.value.length > 2) {
contours.value = contours.value.slice(2);
} else if(contours.length === 0) {
contours.value = [0, 1];
} else if(contours.length < 2) {
zvalue = parseFloat(contours.value[0]);
contours.value = [zvalue, zvalue + 1];
} else {
contours.value = [
parseFloat(contours.value[0]),
parseFloat(contours.value[1])
];
}
} else {
// Requires a single scalar:
coerce('contours.value', 0);

if(!isNumeric(contours.value)) {
if(Array.isArray(contours.value)) {
contours.value = parseFloat(contours.value[0]);
} else {
contours.value = 0;
}
}
}
}
52 changes: 0 additions & 52 deletions src/traces/contour/constraint_value_defaults.js

This file was deleted.

0