Skip to content

Fixing ohlc showing wrong color when opening equals closing #1619

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

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 53 additions & 3 deletions src/traces/ohlc/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,15 +95,65 @@ exports.makeTransform = function(traceIn, state, direction) {
};

exports.getFilterFn = function(direction) {

var fn;
var isPrevThisDirection = null;
var oprev = null;
var cprev = null;

switch(direction) {
case 'increasing':
return function(o, c) { return o <= c; };
var fn = function(o, c) {
if(o === c) {
if(c > cprev) {
return true; // increasing
} else if(c < cprev) {
return false; // decreasing
} else {
if(isPrevThisDirection === true) {
return true; // determine by last candle
} else if(isPrevThisDirection === false) {
return false; // determine by last candle
} else {
return true; // If we don't have previous data, assume it was increasing
}
}
}
return o < c;
};
break;

case 'decreasing':
return function(o, c) { return o > c; };
var fn = function(o, c) {
if(o === c) {
if(c > cprev) {
return false; // increasing
} else if(c < cprev) {
return true; // decreasing
} else {
if(isPrevThisDirection === true) {
return true; // determine by last candle
} else if(isPrevThisDirection === false) {
return false; // determine by last candle
} else {
return false; // If we don't have previous data, assume it was increasing
}
}
}
return o > c;
};
break
}
};

return function(o, c) {
var out = fn(o, c);
isPrevThisDirection = !!out;
oprev = o;
cprev = c;
return out;
};

};
exports.addRangeSlider = function(data, layout) {
var hasOneVisibleTrace = false;

Expand Down