Skip to content

Commit

Permalink
shorten sieve option keys
Browse files Browse the repository at this point in the history
  • Loading branch information
etpinard committed Mar 28, 2019
1 parent 8a5c655 commit c019c5c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
16 changes: 8 additions & 8 deletions src/traces/bar/cross_trace_calc.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,8 @@ function setGroupPositionsInOverlayMode(gd, pa, sa, calcTraces) {
var calcTrace = calcTraces[i];

var sieve = new Sieve([calcTrace], {
separateNegativeValues: false,
dontMergeOverlappingData: !barnorm
sepNegVal: false,
overlapNoMerge: !barnorm
});

// set bar offsets and widths, and update position axis
Expand All @@ -191,8 +191,8 @@ function setGroupPositionsInGroupMode(gd, pa, sa, calcTraces) {
var barnorm = fullLayout.barnorm;

var sieve = new Sieve(calcTraces, {
separateNegativeValues: false,
dontMergeOverlappingData: !barnorm
sepNegVal: false,
overlapNoMerge: !barnorm
});

// set bar offsets and widths, and update position axis
Expand All @@ -217,8 +217,8 @@ function setGroupPositionsInStackOrRelativeMode(gd, pa, sa, calcTraces) {
var barnorm = fullLayout.barnorm;

var sieve = new Sieve(calcTraces, {
separateNegativeValues: barmode === 'relative',
dontMergeOverlappingData: !(barnorm || barmode === 'stack' || barmode === 'relative')
sepNegVal: barmode === 'relative',
overlapNoMerge: !(barnorm || barmode === 'stack' || barmode === 'relative')
});

// set bar offsets and widths, and update position axis
Expand Down Expand Up @@ -591,8 +591,8 @@ function unhideBarsWithinTrace(gd, sa, sieve) {

if(fullTrace.base === undefined) {
var inTraceSieve = new Sieve([calcTrace], {
separateNegativeValues: true,
dontMergeOverlappingData: true
sepNegVal: true,
overlapNoMerge: true
});

for(var j = 0; j < calcTrace.length; j++) {
Expand Down
18 changes: 9 additions & 9 deletions src/traces/bar/sieve.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,16 @@ var BADNUM = require('../../constants/numerical').BADNUM;
* @param {Array} traces
* Array of calculated traces
* @param {object} opts
* - @param {boolean} [separateNegativeValues]
* - @param {boolean} [sepNegVal]
* If true, then split data at the same position into a bar
* for positive values and another for negative values
* - @param {boolean} [dontMergeOverlappingData]
* - @param {boolean} [overlapNoMerge]
* If true, then don't merge overlapping bars into a single bar
*/
function Sieve(traces, opts) {
this.traces = traces;
this.separateNegativeValues = opts.separateNegativeValues;
this.dontMergeOverlappingData = opts.dontMergeOverlappingData;
this.sepNegVal = opts.sepNegVal;
this.overlapNoMerge = opts.overlapNoMerge;

// for single-bin histograms - see histogram/calc
var width1 = Infinity;
Expand Down Expand Up @@ -81,7 +81,7 @@ Sieve.prototype.put = function put(position, value) {
* @method
* @param {number} position Position of datum
* @param {number} [value] Value of datum
* (required if this.separateNegativeValues is true)
* (required if this.sepNegVal is true)
* @returns {number} Current bin value
*/
Sieve.prototype.get = function put(position, value) {
Expand All @@ -95,14 +95,14 @@ Sieve.prototype.get = function put(position, value) {
* @method
* @param {number} position Position of datum
* @param {number} [value] Value of datum
* (required if this.separateNegativeValues is true)
* (required if this.sepNegVal is true)
* @returns {string} Bin label
* (prefixed with a 'v' if value is negative and this.separateNegativeValues is
* (prefixed with a 'v' if value is negative and this.sepNegVal is
* true; otherwise prefixed with '^')
*/
Sieve.prototype.getLabel = function getLabel(position, value) {
var prefix = (value < 0 && this.separateNegativeValues) ? 'v' : '^';
var label = (this.dontMergeOverlappingData) ?
var prefix = (value < 0 && this.sepNegVal) ? 'v' : '^';
var label = (this.overlapNoMerge) ?
position :
Math.round(position / this.binWidth);
return prefix + label;
Expand Down

0 comments on commit c019c5c

Please sign in to comment.