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

Skip to content

Finance refactor #2561

8000
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 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 and test finance hover labels - including test for #1807
  • Loading branch information
alexcjohnson committed Apr 16, 2018
commit 3509b99223cf17d3770b5e56f8fbed0deae863cb
14 changes: 7 additions & 7 deletions src/components/fx/hover.js
Original file line number Diff line number Diff line change
Expand Up @@ -819,13 +819,6 @@ function createHoverText(hoverData, opts, gd) {
}
}

// used by other modules (initially just ternary) that
// manage their own hoverinfo independent of cleanPoint
// the rest of this will still apply, so such modules
// can still put things in (x|y|z)Label, text, and name
// and hoverinfo will still determine their visibility
if(d.extraText !== undefined) text += d.extraText;

if(d.zLabel !== undefined) {
if(d.xLabel !== undefined) text += 'x: ' + d.xLabel + '<br>';
if(d.yLabel !== undefined) text += 'y: ' + d.yLabel + '<br>';
Expand All @@ -844,6 +837,13 @@ function createHoverText(hoverData, opts, gd) {
text += (text ? '<br>' : '') + d.text;
}

// used by other modules (initially just ternary) that
// manage their own hoverinfo independent of cleanPoint
// the rest of this will still apply, so such modules
// can still put things in (x|y|z)Label, text, and name
// and hoverinfo will still determine their visibility
if(d.extraText !== undefined) text += (text ? '<br>' : '') + d.extraText;
Copy link
Contributor

Choose a reason for hiding this comment

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

Why did you have to move this block down?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Our previous users of extraText use only extraText, no x/y/z text, so they're essentially independent of the intervening block. But finance traces use extraText in place of yLabel, and still use xLabel. Contrary to the comment (that I just moved down here with extraText) previously if you had both parts, the x/y/z labels would obliterate extraText.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for the headsup 👌


// if 'text' is empty at this point,
// put 'name' in main label and don't show secondary label
if(text === '') {
Expand Down
23 changes: 14 additions & 9 deletions src/traces/ohlc/hover.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,24 +83,29 @@ module.exports = function hoverPoints(pointData, xval, yval, hovermode) {
return t.labels[attr] + Axes.hoverLabelText(ya, trace[attr][i]);
}

var textParts = [
var hoverinfo = trace.hoverinfo;
var hoverParts = hoverinfo.split('+');
var isAll = hoverinfo === 'all';
var hasY = isAll || hoverParts.indexOf('y') !== -1;
var hasText = isAll || hoverParts.indexOf('text') !== -1;

var textParts = hasY ? [
getLabelLine('open'),
getLabelLine('high'),
getLabelLine('low'),
getLabelLine('close')
];
fillHoverText(di, trace, textParts);
pointData.text = textParts.join('<br>');
getLabelLine('close') + ' ' + DIRSYMBOL[dir]
] : [];
if(hasText) fillHoverText(di, trace, textParts);

// don't make .yLabelVal or .text, since we're managing hoverinfo
// put it all in .extraText
pointData.extraText = textParts.join('<br>');

// this puts the label at the midpoint of the box, ie
// halfway between open and close, not between high and low.
// TODO: the spike also links to this point, whereas previously
// it linked to close. Is one better?
pointData.y0 = pointData.y1 = ya.c2p(di.yc, true);
Copy link
Contributor 78F7

Choose a reason for hiding this comment

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

I think linking to this point is better 👌


// indicate increasing/decreasing in the "name" field
// TODO: only shows up if name is displayed, ie multiple traces.
pointData.name += '<br>' + DIRSYMBOL[dir];

return [pointData];
};
Loading
0