Skip to content

Commit e2f6d0c

Browse files
committed
display mid in the middle
1 parent 3be88c4 commit e2f6d0c

File tree

4 files changed

+17
-13
lines changed

4 files changed

+17
-13
lines changed

src/traces/box/hover.js

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -145,10 +145,10 @@ function hoverOnBoxes(pointData, xval, yval, hovermode) {
145145

146146
// labels with euqual values (e.g. when min === q1) should be presented in certain order
147147
var attrs =
148-
(hasFences && hasMean) ? ['max', 'uf', 'q3', 'mean', 'q1', 'lf', 'min'] :
149-
(hasFences && !hasMean) ? ['max', 'uf', 'q3', 'q1', 'lf', 'min'] :
150-
(!hasFences && hasMean) ? ['max', 'q3', 'mean', 'q1', 'min'] :
151-
['max', 'q3', 'q1', 'min'];
148+
(hasFences && hasMean) ? ['max', 'uf', 'q3', 'med', 'mean', 'q1', 'lf', 'min'] :
149+
(hasFences && !hasMean) ? ['max', 'uf', 'q3', 'med', 'q1', 'lf', 'min'] :
150+
(!hasFences && hasMean) ? ['max', 'q3', 'med', 'mean', 'q1', 'min'] :
151+
['max', 'q3', 'med', 'q1', 'min'];
152152

153153
var rev = vAxis.range[1] < vAxis.range[0];
154154

@@ -159,9 +159,6 @@ function hoverOnBoxes(pointData, xval, yval, hovermode) {
159159
attrs.reverse();
160160
}
161161

162-
// always put median at the start so that it get the extra label
163-
attrs = ['med'].concat(attrs);
164-
165162
var closeBoxData = [];
166163
for(var i = 0; i < attrs.length; i++) {
167164
var attr = attrs[i];
@@ -187,9 +184,15 @@ function hoverOnBoxes(pointData, xval, yval, hovermode) {
187184
}
188185

189186
// only keep name and spikes on the first item (median)
190-
pointData.name = '';
191-
pointData.spikeDistance = undefined;
192-
pointData[spikePosAttr] = undefined;
187+
if(attr === 'med') {
188+
pointData.name = '';
189+
pointData.spikeDistance = undefined;
190+
pointData[spikePosAttr] = undefined;
191+
} else {
192+
pointData2.name = '';
193+
pointData2.spikeDistance = undefined;
194+
pointData2[spikePosAttr] = undefined;
195+
}
193196

194197
// no hovertemplate support yet
195198
pointData2.hovertemplate = false;

test/jasmine/tests/box_test.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -782,10 +782,11 @@ describe('Test box hover:', function() {
782782
},
783783
pos: [350, 200],
784784
nums: [
785+
'23.25',
785786
'median: 8.15', 'min: 0.75', 'q1: 6.8',
786787
'q3: 10.25', 'max: 23.25', 'lower fence: 5.25', 'upper fence: 12'
787788
],
788-
name: ['', '', '', '', '', '', ''],
789+
name: ['', '', '', '', '', '', '', ''],
789790
axis: 'trace 0'
790791
}, {
791792
desc: 'with overlaid boxes',

test/jasmine/tests/hover_label_test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4680,10 +4680,10 @@ describe('hovermode: (x|y)unified', function() {
46804680
'min: 1',
46814681
'lower fence: 1',
46824682
'q1: 1',
4683+
'trace 1 : median: 1',
46834684
'q3: 1',
46844685
'upper fence: 1',
46854686
'max: 1',
4686-
'trace 1 : median: 1',
46874687
'trace 3 : 2',
46884688
'trace 2 : 2',
46894689
'trace 5 : 2',

test/jasmine/tests/violin_test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -552,10 +552,10 @@ describe('Test violin hover:', function() {
552552
name: ['', '', '', '', '', '', ''],
553553
axis: 'Sat',
554554
hoverLabelPos: [
555-
[363, 270],
556555
[338, 270],
557556
[377, 270],
558557
[351, 270],
558+
[363, 270],
559559
[345, 270],
560560
[385, 270],
561561
[347, 270]

0 commit comments

Comments
 (0)