Skip to content

Pass 'name' in hoverinfo for OHLC generated traces #1050

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 2 commits into from
Oct 18, 2016
Merged
Show file tree
Hide file tree
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
15 changes: 8 additions & 7 deletions src/traces/ohlc/transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,18 +100,19 @@ function makeTrace(traceIn, state, direction) {
function makeHoverInfo(traceIn) {
var hoverinfo = traceIn.hoverinfo;

if(hoverinfo === 'all') return 'x+text';
if(hoverinfo === 'all') return 'x+text+name';

var parts = hoverinfo.split('+'),
hasX = parts.indexOf('x') !== -1,
hasText = parts.indexOf('text') !== -1;
indexOfY = parts.indexOf('y'),
indexOfText = parts.indexOf('text');

if(hasX) {
if(hasText) return 'x+text';
else return 'x';
if(indexOfY !== -1) {
parts.splice(indexOfY, 1);

if(indexOfText === -1) parts.push('text');
}
else return 'text';

return parts.join('+');
}

exports.calcTransform = function calcTransform(gd, trace, opts) {
Expand Down
4 changes: 2 additions & 2 deletions test/jasmine/tests/finance_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -390,10 +390,10 @@ describe('finance charts calc transforms:', function() {

var out = _calc([trace0, trace1, trace2, trace3]);

expect(out[0].hoverinfo).toEqual('x+text');
expect(out[0].hoverinfo).toEqual('x+text+name');
expect(out[0].text[0])
.toEqual('Open: 33.01<br>High: 34.2<br>Low: 31.7<br>Close: 34.1<br>A');
expect(out[0].hoverinfo).toEqual('x+text');
expect(out[0].hoverinfo).toEqual('x+text+name');
expect(out[1].text[0])
.toEqual('Open: 33.31<br>High: 34.37<br>Low: 30.75<br>Close: 31.93<br>B');

Expand Down