Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 01df2d2

Browse filesBrowse files
committed
style selected text nodes with selectedTextStyle + add test
1 parent 7103fab commit 01df2d2
Copy full SHA for 01df2d2

File tree

Expand file treeCollapse file tree

3 files changed

+53
-4
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+53
-4
lines changed

‎src/traces/bar/style.js

Copy file name to clipboardExpand all lines: src/traces/bar/style.js
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ function styleOnSelect(gd, cd) {
7676
var trace = cd[0].trace;
7777

7878
if(trace.selectedpoints) {
79-
Drawing.selectedPointStyle(s.selectAll('path'), trace, gd);
80-
Drawing.selectedPointStyle(s.selectAll('text'), trace, gd);
79+
Drawing.selectedPointStyle(s.selectAll('path'), trace);
80+
Drawing.selectedTextStyle(s.selectAll('text'), trace);
8181
} else {
8282
stylePoints(s, trace, gd);
8383
}

‎src/traces/scatter/style.js

Copy file name to clipboardExpand all lines: src/traces/scatter/style.js
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ function styleOnSelect(gd, cd) {
5050
var trace = cd[0].trace;
5151

5252
if(trace.selectedpoints) {
53-
Drawing.selectedPointStyle(s.selectAll('path.point'), trace, gd);
54-
Drawing.selectedPointStyle(s.selectAll('text'), trace, gd);
53+
Drawing.selectedPointStyle(s.selectAll('path.point'), trace);
54+
Drawing.selectedTextStyle(s.selectAll('text'), trace);
5555
} else {
5656
stylePoints(s, trace, gd);
5757
}

‎test/jasmine/tests/select_test.js

Copy file name to clipboardExpand all lines: test/jasmine/tests/select_test.js
+49Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1485,6 +1485,55 @@ describe('@flaky Test select box and lasso per trace:', function() {
14851485
.catch(failTest)
14861486
.then(done);
14871487
});
1488+
1489+
it('should work on scatter/bar traces with text nodes', function(done) {
1490+
var assertSelectedPoints = makeAssertSelectedPoints();
1491+
1492+
function assertFillOpacity(exp) {
1493+
var txtPts = d3.select(gd).select('g.plot').selectAll('text');
1494+
1495+
expect(txtPts.size()).toBe(exp.length, '# of text nodes');
1496+
1497+
txtPts.each(function(_, i) {
1498+
var act = Number(this.style['fill-opacity']);
1499+
expect(act).toBe(exp[i], 'node ' + i + ' fill opacity');
1500+
});
1501+
}
1502+
1503+
Plotly.plot(gd, [{
1504+
mode: 'markers+text',
1505+
x: [1, 2, 3],
1506+
y: [1, 2, 1],
1507+
text: ['a', 'b', 'c']
1508+
}, {
1509+
type: 'bar',
1510+
x: [1, 2, 3],
1511+
y: [1, 2, 1],
1512+
text: ['A', 'B', 'C'],
1513+
textposition: 'outside'
1514+
}], {
1515+
dragmode: 'select',
1516+
showlegend: false,
1517+
width: 400,
1518+
height: 400,
1519+
margin: {l: 0, t: 0, r: 0, b: 0}
1520+
})
1521+
.then(function() {
1522+
return _run(
1523+
[[10, 10], [100, 300]],
1524+
function() {
1525+
assertSelectedPoints({0: [0], 1: [0]});
1526+
assertFillOpacity([1, 0.2, 0.2, 1, 0.2, 0.2]);
1527+
},
1528+
null, BOXEVENTS, 'selecting first scatter/bar text nodes'
1529+
);
1530+
})
1531+
.then(function() {
1532+
assertFillOpacity([1, 1, 1, 1, 1, 1]);
1533+
})
1534+
.catch(failTest)
1535+
.then(done);
1536+
});
14881537
});
14891538

14901539
describe('Test that selections persist:', function() {

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.