8000 Finance refactor by alexcjohnson · Pull Request #2561 · plotly/plotly.js · GitHub
[go: up one dir, main page]

Skip to content

Finance refactor #2561

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintain 8000 ers 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 25 commits into from
Apr 17, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
e979cf0
refactor candlestick into a first-class trace, also box/violin hover …
alexcjohnson Apr 5, 2018
84c36a9
refactor OHLC into a first-class trace type
alexcjohnson Apr 6, 2018
3870503
update non-finance tests for finance refactor
alexcjohnson Apr 10, 2018
4c46a73
fix finance tests - with a couple of bugfixes too
alexcjohnson Apr 13, 2018
94c4560
fix #2004
alexcjohnson Apr 13, 2018
3509b99
fix and test finance hover labels - including test for #1807
alexcjohnson Apr 13, 2018
2849ff9
test finance trace select
alexcjohnson Apr 16, 2018
be2b523
:hocho: hover test in finance_test - hover_label_test covers it better
alexcjohnson Apr 16, 2018
5b6a7d5
fix prereqs for transform_multi_test
alexcjohnson Apr 16, 2018
121d171
update finance bundle tests
alexcjohnson Apr 16, 2018
ad1d8f0
update finance mocks
alexcjohnson Apr 16, 2018
2554482
fix lf/uf vs min/max logic for box/violin/candlestick
alexcjohnson Apr 16, 2018
0d80a21
fix #2510 - or rather, revive the test that the refactor fixed this
alexcjohnson Apr 16, 2018
82677ac
tweak and test cleanData for finance traces
alexcjohnson Apr 16, 2018
71fa112
remove plotSchema change from before we decided to refactor finance t…
alexcjohnson Apr 16, 2018
0b7541e
fix for box & candlestick together on one subplot
alexcjohnson Apr 16, 2018
f84dfae
change to shorter dash in finance_style mock
alexcjohnson Apr 16, 2018
d64fab6
remove TODO that's been OK'd as is
alexcjohnson Apr 16, 2018
dc01685
undefined -> BADNUM in ohlc/calc
alexcjohnson Apr 16, 2018
c8b03ee
Merge branch 'master' into finance-refactor
alexcjohnson Apr 17, 2018
302d1e6
update new getModuleCalcData callers to new API
alexcjohnson Apr 17, 2018
f498bd0
set to null instead of delete in ohlc/calc
alexcjohnson Apr 17, 2018
c77a8a3
test that selection applies to plot, not rangeslider
alexcjohnson Apr 17, 2018
3f43253
:hocho: fit
alexcjohnson Apr 17, 2018
13204a9
mark polar drag test flaky
alexcjohnson Apr 17, 2018
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
Prev Previous commit
Next Next commit
fix finance tests - with a couple of bugfixes too
  • Loading branch information
alexcjohnson committed Apr 16, 2018
commit 4c46a73d0851ebbf262d462485670e51f46de114
4 changes: 1 addition & 3 deletions src/lib/coerce.js
Original file line number Diff line number Diff line change
Expand Up @@ -433,9 +433,7 @@ exports.coerceFont = function(coerce, attr, dfltObj) {
*/
exports.coerceHoverinfo = function(traceIn, traceOut, layoutOut) {
var moduleAttrs = traceOut._module.attributes;
var attrs = moduleAttrs.hoverinfo ?
{hoverinfo: moduleAttrs.hoverinfo} :
baseTraceAttrs;
var attrs = moduleAttrs.hoverinfo ? moduleAttrs : baseTraceAttrs;

var valObj = attrs.hoverinfo;
var dflt;
Expand Down
11 changes: 9 additions & 2 deletions src/traces/ohlc/calc.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ function calcCommon(gd, trace, x, ya, ptFunc) {

// we're optimists - before we have any changing data, assume increasing
var increasing = true;
var cPrev = null;

var cd = [];
for(var i = 0; i < x.length; i++) {
Expand All @@ -69,8 +70,14 @@ function calcCommon(gd, trace, x, ya, ptFunc) {
var ci = c[i];

if(xi !== undefined && oi !== undefined && hi !== undefined && li !== undefined && ci !== undefined) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm. you mean BADNUM 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 call, yes BADNUM -> dc01685

// increasing carries over from previous if ci===oi
increasing = (ci === oi) ? increasing : ci > oi;
if(ci === oi) {
// if open == close, look for a change from the previous close
if(cPrev !== null && ci !== cPrev) increasing = ci > cPrev;
8000 // else (c === cPrev or cPrev is null) no change
}
else increasing = ci > oi;
Copy link
Contributor

Choose a reason for hiding this comment

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

What does this fix exactly?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is code that used to be in _isIncreasing that I didn't copy over right the first time, but it affects fallbacks when open===close, as tested here


cPrev = ci;

var pt = ptFunc(oi, hi, li, ci);

Expand Down
6 changes: 5 additions & 1 deletion src/traces/ohlc/hover.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ module.exports = function hoverPoints(pointData, xval, yval, hovermode) {
var trace = cd[0].trace;
var t = cd[0].t;

var type = trace.type;
var minAttr = type === 'ohlc' ? 'l' : 'min';
var maxAttr = type === 'ohlc' ? 'h' : 'max';

// potentially shift xval for grouped candlesticks
var centerShift = t.bPos || 0;
var x0 = xval - centerShift;
Expand All @@ -44,7 +48,7 @@ module.exports = function hoverPoints(pointData, xval, yval, hovermode) {
}

function dy(di) {
return Fx.inbox(di.min - yval, di.max - yval, hoverPseudoDistance);
return Fx.inbox(di[minAttr] - yval, di[maxAttr] - yval, hoverPseudoDistance);
}

function dxy(di) { return (dx(di) + dy(di)) / 2; }
Expand Down
Loading
0