Skip to content

Commit cd1eaef

Browse files
committed
add ct key to choropleth* event data
... which makes `%{ct}` available to hovertemplate strings!
1 parent 5854f6f commit cd1eaef

File tree

4 files changed

+8
-7
lines changed

4 files changed

+8
-7
lines changed

src/traces/choropleth/event_data.js

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ module.exports = function eventData(out, pt, trace, cd, pointNumber) {
1717
if(cdi.fIn && cdi.fIn.properties) {
1818
out.properties = cdi.fIn.properties;
1919
}
20+
out.ct = cdi.ct;
2021

2122
return out;
2223
};

test/jasmine/tests/choropleth_test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -306,10 +306,10 @@ describe('Test choropleth hover:', function() {
306306
it('should include *properties* from input custom geojson', function(done) {
307307
var fig = Lib.extendDeep({}, require('@mocks/geo_custom-geojson.json'));
308308
fig.data = [fig.data[1]];
309-
fig.data[0].hovertemplate = '%{properties.name}<extra></extra>';
309+
fig.data[0].hovertemplate = '%{properties.name}<extra>%{ct[0]:.1f} | %{ct[1]:.1f}</extra>';
310310
fig.layout.geo.projection = {scale: 20};
311311

312-
run([300, 200], fig, ['New York']).then(done);
312+
run([300, 200], fig, ['New York', '-75.1 | 42.6']).then(done);
313313
});
314314
});
315315

test/jasmine/tests/choroplethmapbox_test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -622,11 +622,11 @@ describe('@noCI Test choroplethmapbox hover:', function() {
622622
fig.data = [fig.data[1]];
623623
fig.data[0].locations = [100];
624624
fig.data[0].geojson.id = 100;
625-
fig.data[0].hovertemplate = '### %{location}<extra>%{location} ###</extra>';
625+
fig.data[0].hovertemplate = '### %{location}<extra>%{ct[0]:.1f} | %{ct[1]:.1f} ###</extra>';
626626
return fig;
627627
},
628628
nums: '### 100',
629-
name: '100 ###',
629+
name: '-86.7 | 32.0 ###',
630630
evtPts: [{location: 100, z: 10, pointNumber: 0, curveNumber: 0}]
631631
}];
632632

test/jasmine/tests/geo_test.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -861,7 +861,7 @@ describe('Test geo interactions', function() {
861861
it('should contain the correct fields', function() {
862862
expect(Object.keys(ptData)).toEqual([
863863
'data', 'fullData', 'curveNumber', 'pointNumber', 'pointIndex',
864-
'location', 'z'
864+
'location', 'z', 'ct'
865865
]);
866866
});
867867

@@ -889,7 +889,7 @@ describe('Test geo interactions', function() {
889889
it('should contain the correct fields', function() {
890890
expect(Object.keys(ptData)).toEqual([
891891
'data', 'fullData', 'curveNumber', 'pointNumber', 'pointIndex',
892-
'location', 'z'
892+
'location', 'z', 'ct'
893893
]);
894894
});
895895

@@ -921,7 +921,7 @@ describe('Test geo interactions', function() {
921921
it('should contain the correct fields', function() {
922922
expect(Object.keys(ptData)).toEqual([
923923
'data', 'fullData', 'curveNumber', 'pointNumber', 'pointIndex',
924-
'location', 'z'
924+
'location', 'z', 'ct'
925925
]);
926926
});
927927

0 commit comments

Comments
 (0)