mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
Hide tooltip when checkbox is unselected (#10330)
Backports PR #10260
Hide tooltip when unselected
* Original sha: 3bfc81c9b3
* Authored by Thomas Neirynck <thomas@elastic.co> on 2017-02-09T06:14:23Z
This commit is contained in:
parent
2cfe54a8da
commit
4fed034993
4 changed files with 14 additions and 9 deletions
|
@ -42,13 +42,14 @@ describe('tilemaptest - Marker Tests', function () {
|
|||
let mapData;
|
||||
let markerLayer;
|
||||
|
||||
function createMarker(MarkerClass, geoJson) {
|
||||
function createMarker(MarkerClass, geoJson, tooltipFormatter) {
|
||||
mapData = _.assign({}, geoJsonData.geoJson, geoJson || {});
|
||||
mapData.properties.allmin = mapData.properties.min;
|
||||
mapData.properties.allmax = mapData.properties.max;
|
||||
|
||||
return new MarkerClass(mockMap, mapData, {
|
||||
valueFormatter: geoJsonData.valueFormatter
|
||||
valueFormatter: geoJsonData.valueFormatter,
|
||||
tooltipFormatter: tooltipFormatter || null
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -143,15 +144,14 @@ describe('tilemaptest - Marker Tests', function () {
|
|||
|
||||
describe('showTooltip', function () {
|
||||
it('should use the tooltip formatter', function () {
|
||||
let content;
|
||||
const sample = _.sample(mapData.features);
|
||||
|
||||
markerLayer = createMarker(MarkerClass, null, Function.prototype);//create marker with tooltip
|
||||
markerLayer._attr.addTooltip = true;
|
||||
const stub = sinon.stub(markerLayer, '_tooltipFormatter', function (val) {
|
||||
return;
|
||||
});
|
||||
|
||||
markerLayer._showTooltip(sample);
|
||||
|
||||
expect(stub.callCount).to.equal(1);
|
||||
expect(stub.firstCall.calledWith(sample)).to.be(true);
|
||||
});
|
||||
|
|
|
@ -38,7 +38,7 @@ export default function MapFactory(Private, tilemapSettings) {
|
|||
this._events = _.get(params, 'events');
|
||||
this._markerType = markerTypes[params.markerType] ? params.markerType : defaultMarkerType;
|
||||
this._valueFormatter = params.valueFormatter || _.identity;
|
||||
this._tooltipFormatter = params.tooltipFormatter || _.identity;
|
||||
this._tooltipFormatter = params.tooltipFormatter;
|
||||
this._geoJson = _.get(this._chartData, 'geoJson');
|
||||
this._attr = params.attr || {};
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ export default function MarkerFactory() {
|
|||
this.geoJson = geoJson;
|
||||
this.popups = [];
|
||||
|
||||
this._tooltipFormatter = params.tooltipFormatter || _.identity;
|
||||
this._tooltipFormatter = params.tooltipFormatter || null;
|
||||
this._valueFormatter = params.valueFormatter || _.identity;
|
||||
this._attr = params.attr || {};
|
||||
|
||||
|
@ -218,7 +218,11 @@ export default function MarkerFactory() {
|
|||
* @return undefined
|
||||
*/
|
||||
_showTooltip(feature, latLng) {
|
||||
if (!this.map) return;
|
||||
const hasMap = !!this.map;
|
||||
const hasTooltip = !!this._attr.addTooltip;
|
||||
if (!hasMap || !hasTooltip) {
|
||||
return;
|
||||
}
|
||||
const lat = _.get(feature, 'geometry.coordinates.1');
|
||||
const lng = _.get(feature, 'geometry.coordinates.0');
|
||||
latLng = latLng || L.latLng(lat, lng);
|
||||
|
|
|
@ -98,12 +98,13 @@ export default function TileMapFactory(Private) {
|
|||
|
||||
const params = _.assign({}, _.get(this._chartData, 'geoAgg.vis.params'), uiStateParams);
|
||||
|
||||
const tooltipFormatter = this.handler.visConfig.get('addTooltip') ? this.tooltipFormatter : null;
|
||||
const map = new TileMapMap(container, this._chartData, {
|
||||
center: params.mapCenter,
|
||||
zoom: params.mapZoom,
|
||||
events: this.events,
|
||||
markerType: this.handler.visConfig.get('mapType'),
|
||||
tooltipFormatter: this.tooltipFormatter,
|
||||
tooltipFormatter: tooltipFormatter,
|
||||
valueFormatter: this.valueFormatter,
|
||||
attr: this.handler.visConfig._values
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue