Skip to content

Commit 8e8670d

Browse files
committed
fill rLabel and thetaLabel during scatterpolar and barpolar hover
1 parent 8cf5135 commit 8e8670d

File tree

4 files changed

+16
-14
lines changed

4 files changed

+16
-14
lines changed

Diff for: src/traces/scatterpolar/hover.js

+11-11
Original file line numberDiff line numberDiff line change
@@ -42,26 +42,26 @@ function makeHoverPointText(cdi, trace, subplot, pointData) {
4242
radialAxis._hovertitle = 'r';
4343
angularAxis._hovertitle = 'θ';
4444

45+
var rVal = radialAxis.c2l(cdi.r);
46+
pointData.rLabel = Axes.tickText(radialAxis, rVal, 'hover').text;
47+
48+
// N.B here the ° sign is part of the formatted value for thetaunit:'degrees'
49+
var thetaVal = angularAxis.thetaunit === 'degrees' ? Lib.rad2deg(cdi.theta) : cdi.theta;
50+
pointData.thetaLabel = Axes.tickText(angularAxis, thetaVal, 'hover').text;
51+
4552
var hoverinfo = cdi.hi || trace.hoverinfo;
4653
var text = [];
4754
function textPart(ax, val) {
48-
text.push(ax._hovertitle + ': ' + Axes.tickText(ax, val, 'hover').text);
55+
text.push(ax._hovertitle + ': ' + val);
4956
}
5057

5158
if(!trace.hovertemplate) {
5259
var parts = hoverinfo.split('+');
5360

5461
if(parts.indexOf('all') !== -1) parts = ['r', 'theta', 'text'];
55-
if(parts.indexOf('r') !== -1) {
56-
textPart(radialAxis, radialAxis.c2l(cdi.r));
57-
}
58-
if(parts.indexOf('theta') !== -1) {
59-
var theta = cdi.theta;
60-
textPart(
61-
angularAxis,
62-
angularAxis.thetaunit === 'degrees' ? Lib.rad2deg(theta) : theta
63-
);
64-
}
62+
if(parts.indexOf('r') !== -1) textPart(radialAxis, pointData.rLabel);
63+
if(parts.indexOf('theta') !== -1) textPart(angularAxis, pointData.thetaLabel);
64+
6565
if(parts.indexOf('text') !== -1 && pointData.text) {
6666
text.push(pointData.text);
6767
delete pointData.text;

Diff for: test/jasmine/tests/barpolar_test.js

+2
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,8 @@ describe('Test barpolar hover:', function() {
128128
index: 0,
129129
x: 263.33,
130130
y: 200,
131+
rLabel: '1',
132+
thetaLabel: '0°',
131133
hovertemplate: 'tpl',
132134
color: '#1f77b4'
133135
}

Diff for: test/jasmine/tests/scatterpolar_test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ describe('Test scatterpolar hover:', function() {
115115
fig.data[2].hovertemplate = 'template %{r} %{theta}';
116116
return fig;
117117
},
118-
nums: 'template 4.02289202968 128.342009045',
118+
nums: 'template 4.022892 128.342°',
119119
name: 'Trial 3'
120120
}, {
121121
desc: 'with hovertemplate and empty trace name',
@@ -124,7 +124,7 @@ describe('Test scatterpolar hover:', function() {
124124
fig.data[2].name = '';
125125
return fig;
126126
},
127-
nums: 'template 4.02289202968 128.342009045',
127+
nums: 'template 4.022892 128.342°',
128128
name: ''
129129
}, {
130130
desc: '(no labels - out of sector)',

Diff for: test/jasmine/tests/scatterpolargl_test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ describe('Test scatterpolargl hover:', function() {
5050
fig.data[2].hovertemplate = 'template %{r} %{theta}';
5151
return fig;
5252
},
53-
nums: 'template 3.88601339194 125.282157112',
53+
nums: 'template 3.886013 125.2822°',
5454
name: 'Trial 3'
5555
}, {
5656
desc: '(no labels - out of sector)',

0 commit comments

Comments
 (0)