Skip to content

Commit 85d7061

Browse files
committedOct 3, 2017
allow choropleth trace to have (trace-wide) string 'text' values
1 parent 0a77239 commit 85d7061

File tree

3 files changed

+23
-5
lines changed

3 files changed

+23
-5
lines changed
 

Diff for: ‎src/traces/choropleth/attributes.js

+2-4
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,9 @@ module.exports = extendFlat({
3434
editType: 'calc',
3535
description: 'Sets the color values.'
3636
},
37-
text: {
38-
valType: 'data_array',
39-
editType: 'calc',
37+
text: extendFlat({}, ScatterGeoAttrs.text, {
4038
description: 'Sets the text elements associated with each location.'
41-
},
39+
}),
4240
marker: {
4341
line: {
4442
color: ScatterGeoMarkerLineAttrs.color,

Diff for: ‎src/traces/choropleth/hover.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,14 @@ function makeHoverInfo(pointData, trace, pt, axis) {
7979
}
8080

8181
if(hasZ) text.push(formatter(pt.z));
82-
if(hasText) text.push(pt.tx);
82+
if(hasText) {
83+
var tx;
84+
85+
if(pt.tx) tx = pt.tx;
86+
else if(trace.text) tx = trace.text;
87+
88+
if(!Array.isArray(tx)) text.push(tx);
89+
}
8390

8491
pointData.extraText = text.join('<br>');
8592
}

Diff for: ‎test/jasmine/tests/choropleth_test.js

+13
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,19 @@ describe('Test choropleth hover:', function() {
9393
.then(done);
9494
});
9595

96+
it('should generate hover label info (\'text\' single value case)', function(done) {
97+
var fig = Lib.extendDeep({}, require('@mocks/geo_first.json'));
98+
fig.data[1].text = 'tExT';
99+
fig.data[1].hoverinfo = 'text';
100+
101+
run(
102+
[400, 160],
103+
fig,
104+
['tExT', null]
105+
)
106+
.then(done);
107+
});
108+
96109
it('should generate hover label info (\'text\' array case)', function(done) {
97110
var fig = Lib.extendDeep({}, require('@mocks/geo_first.json'));
98111
fig.data[1].text = ['tExT', 'TeXt', '-text-'];

0 commit comments

Comments
 (0)
Please sign in to comment.