Skip to content

Commit 01fe6ee

Browse files
committed
scattergl: do not mutate text array
1 parent 11c9879 commit 01fe6ee

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

src/traces/scattergl/convert.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,8 @@ function convertTextStyle(trace) {
112112
var i;
113113

114114
optsOut.text = trace.text;
115-
if(Array.isArray(optsOut.text)) {
115+
if(Array.isArray(optsOut.text) && optsOut.text.length < count) {
116+
optsOut.text = trace.text.slice();
116117
for(i = optsOut.text.length; i < count; i++) {
117118
optsOut.text[i] = '';
118119
}

test/jasmine/tests/scattergl_test.js

+8-3
Original file line numberDiff line numberDiff line change
@@ -107,14 +107,19 @@ describe('end-to-end scattergl tests', function() {
107107

108108
it('@gl should handle a plot with less text labels than data points', function(done) {
109109
expect(function() {
110-
Plotly.plot(gd, [{
110+
var mock = {
111111
'type': 'scattergl',
112112
'mode': 'markers+text',
113113
'x': [3, 2, 1, 0],
114114
'y': [0, 1, 4, 9],
115-
'text': ['1', '2', '3'],
116115
'textposition': 'top center'
117-
}]);
116+
};
117+
mock.text = ['1', '2', '3'];
118+
Plotly.plot(gd, [mock])
119+
.then(function() {
120+
expect(mock.text.length).toBe(3);
121+
})
122+
.catch(failTest);
118123
}).not.toThrow();
119124
done();
120125
});

0 commit comments

Comments
 (0)