Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade kibana to leaflet 1.x #12367

Merged
merged 24 commits into from
Aug 22, 2017
Merged

Upgrade kibana to leaflet 1.x #12367

merged 24 commits into from
Aug 22, 2017

Conversation

nreese
Copy link
Contributor

@nreese nreese commented Jun 15, 2017

To use PR, uninstall old leaflet modules and install new modules with npm install

Uses leaflet-responsive-popup plugin to fix Tile Map tooltips near edges of map are cut off

Unable to upgrade to leaflet 1.1.0 because 1.1.0 breaks most leaflet plugins, like leaflet.draw - TypeError: can't define property "segmentsIntersect": Object is not extensible

backported to 6.0 #13669
backported to 6.x #13688

@thomasneirynck thomasneirynck self-requested a review June 28, 2017 23:00
@thomasneirynck thomasneirynck added Feature:Visualizations Generic visualization features (in case no more specific feature label is available) release_note:enhancement labels Jun 28, 2017
@thomasneirynck
Copy link
Contributor

Closes #10276.

@thomasneirynck
Copy link
Contributor

jenkins, test this

Copy link
Contributor

@thomasneirynck thomasneirynck left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a real nice update. The map is decidedly more responsive. It will also set us up to work with the latest-greatest Leaflet features.

Two things jump out:

  • we'll need a new way to regression test the map. Currently, tests would verify that the SVG-content on the map was correct. Now, with Leaflet using html5-canvas, there is no access to such an easily queryable content in the DOM. Testing the correct data on the map has proven to be a good way to catch regressions, and we should retain a mechanism that is sufficiently reliable. I would consider experimenting with screenshot-comparisons for this https://github.com/mapbox/pixelmatch. Basically, test if the leaflet-canvas looks the way it should. But open to all other approaches.
  • The upgrade heatmap layer is unstable.
    • It has this visual artifact where the layer doesn't zoom along smoothly with the map, but lags and then snaps. I can reproduce this on FF in Linux and chrome/ff/IE/edge on Windows (unsure about Mac).
    • It also continues to display the following issue Failed to execute 'getImageData' on 'CanvasRenderingContext2D' on tilemap #13293, something we've had since forever. I feel like it's worse now (but that's just a gut-feeling, no specific steps to reproduce).

It may be useful to experiment with other implementations of the heatmap layer, that may have a more reliable implementation (?) (http://leafletjs.com/plugins.html#heatmaps). This may also benefit the simplification of the heatlayer options: #11759.

Copy link
Contributor

@thomasneirynck thomasneirynck left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested this and I think it is a genuine nice addition. Particularly the heatmap simplification is really nice. The heuristics work well imo. we can always tinker more too.

I've been looking at it with some larger datasets. (300000+ records) and remains responsive. we can try a couple more ('real' ones) in the weeks to come/beta period.

Small thing: I ran into this, but for the love of me don't know how exactly (probably not related to this pr). failing at https://github.com/thomasneirynck/kibana/blob/23d903746383c2fc3d55c0cf1075a686aa6cb0a9/src/core_plugins/tile_map/public/maps_visualization.js#L305-L305
image

@@ -13,69 +13,6 @@
<div ng-if="vis.params.mapType === 'Heatmap'" class="form-group">
<div>
<label>
Radius
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 💯

maxZoom: parseFloat(this._geohashOptions.heatmap.heatMaxZoom),
radius: radius,
blur: radius * 0.75,
maxZoom: this._kibanaMap.getZoomLevel(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should not use the zoom-level of the current map (because that may change for a given precision). Instead, the lowest zoom level that correspond to the current ES-precision on the map. I think that would yield more consistent results. It would make the construction for new heatmap-marker layer consistent for every ES-precision-result . By using the current zoom level, depending on where you are in the zoom, this layer could get instantiated with any of the 2-3 zoom levels that correspond to a given ES-precision.

blur: parseFloat(this._geohashOptions.heatmap.heatBlur),
maxZoom: parseFloat(this._geohashOptions.heatmap.heatMaxZoom),
radius: radius,
blur: radius * 0.75,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

imho, could be a tad blurrier, but that's just me.


export function gridDimensions(precision) {
return _.get(gridAtEquator, precision);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice utility. Would you mind moving kibana/src/ui/public/utils/zoom_to_precision.js to this folder as well? for some reason, that ended up in some rando util folder, but would fit much better alongside this module here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this the best place for zoom_to_precision? Precision is used to create aggregation request. I stuck grid_dimensions into the aggregation response folder since it is used on the response. Maybe there should be a top level geo_utils folder so geo stuff can be gathered into a single place that is outside of aggregation and visualizations.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok. makes sense

</div>
</div>
<div>
<label>
Minimum opacity
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd label this as something more wishy-washy: 'Granularity', 'Intensity'. The reason for that is that it ties us less to the L.heatlayer implementation and would make it easier to backfill this generic property with another heat-implementation.

Range form 0-1 remains good though.

const latLngY = this._leafletMap.containerPointToLatLng(pointY);

const distanceX = latLngC.distanceTo(latLngX); // calculate distance between c and x (latitude)
const distanceY = latLngC.distanceTo(latLngY); // calculate distance between c and y (longitude)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good idea to measure the diagonal. heatmap-grids change aspect-ratio per zoom level, this is a good approximation.

zoom: options.zoom ? options.zoom : 2
zoom: options.zoom ? options.zoom : 2,
renderer: L.canvas(),
zoomAnimation: false // Desaturate map tiles causes animation rendering artifacts
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok to switch this off for now.

Client-side desaturation is a problem. we need a base-layer on the server-side that's already desaturated and work towards vector mapping on the client.

@@ -100,7 +100,9 @@ export class KibanaMap extends EventEmitter {
minZoom: options.minZoom,
maxZoom: options.maxZoom,
center: options.center ? options.center : [0, 0],
zoom: options.zoom ? options.zoom : 2
zoom: options.zoom ? options.zoom : 2,
renderer: L.canvas(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nreese
Copy link
Contributor Author

nreese commented Aug 8, 2017

@thomasneirynck

Should the heatmap intensity change based on the min/max range? The other geohash layers vary the number of categories based on the the range. Should heatmap mimic this? For example, when the range is below 2, the intensity would be 0.9. When the range is between 2 and 24, the intensity is 0.6. And for everything else, the intensity is 0.1.

The cutoffs of 2 and 24 seem arbitrary. Would there be a better way to create the cutoffs based on statistical values?

@nreese
Copy link
Contributor Author

nreese commented Aug 18, 2017

jenkins, test this

Copy link
Member

@ppisljar ppisljar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks a lot @nreese this is amazing!

@thomasneirynck
Copy link
Contributor

jenkins, test this

Copy link
Contributor

@thomasneirynck thomasneirynck left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

the simplified heatmap controls are really nice!

Can you create a new issue for the missing region maps test and put a 6.0 GA label on it?


export function gridDimensions(precision) {
return _.get(gridAtEquator, precision);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok. makes sense

@nreese
Copy link
Contributor Author

nreese commented Aug 22, 2017

@thomasneirynck I created the issue for region map tests, #13652

@thomasneirynck
Copy link
Contributor

@nreese
Copy link
Contributor Author

nreese commented Aug 22, 2017

@thomasneirynck Will do. While in the ascii docs, I will also update https://github.com/elastic/kibana/blob/master/docs/migration/migrate_6_0.asciidoc

@nreese nreese merged commit 599c8c4 into elastic:master Aug 22, 2017
@thomasneirynck
Copy link
Contributor

🚀

nreese added a commit to nreese/kibana that referenced this pull request Aug 23, 2017
* upgrade leaflet modules to 1.x latest

* fix css for leaflet controls

* update draw options so it is easier to see polygon when drawing

* fix chrome touch issues with closing polygon in leaflet draw

* use canvas renderer

* use leaflet-responsive-popup to avoid tooltip cutoff

* remove radius configuration from leaflet heatmap

* make blur a factor of radius. Set maxZoom to map zoom since new values are calculated per precision

* use _.get to avoid error, cannot read property of undefined

* add cluster size slider

* experiments with image differences

* onload not onLoad

* use canvas dimensions

* compare map canvas to stored PNG of map canvas

* remove pixelmatch from project dependecies

* fix broken test - rounding error

* add expected image tests for geohash layers shaded circles and geohash grids

* bump z-index of vis-spy

* update functional test expected data

* update to leaflet 1.2.0

* revert to leaflet 1.0.3 and update expected data set for map functional tests

* test geohash_layer heatmap in unit test

* update region_map functional test since it can not longer pluck map vectors from DOM

* update documentation
nreese added a commit that referenced this pull request Aug 23, 2017
* upgrade leaflet modules to 1.x latest

* fix css for leaflet controls

* update draw options so it is easier to see polygon when drawing

* fix chrome touch issues with closing polygon in leaflet draw

* use canvas renderer

* use leaflet-responsive-popup to avoid tooltip cutoff

* remove radius configuration from leaflet heatmap

* make blur a factor of radius. Set maxZoom to map zoom since new values are calculated per precision

* use _.get to avoid error, cannot read property of undefined

* add cluster size slider

* experiments with image differences

* onload not onLoad

* use canvas dimensions

* compare map canvas to stored PNG of map canvas

* remove pixelmatch from project dependecies

* fix broken test - rounding error

* add expected image tests for geohash layers shaded circles and geohash grids

* bump z-index of vis-spy

* update functional test expected data

* update to leaflet 1.2.0

* revert to leaflet 1.0.3 and update expected data set for map functional tests

* test geohash_layer heatmap in unit test

* update region_map functional test since it can not longer pluck map vectors from DOM

* update documentation
@epixa
Copy link
Contributor

epixa commented Aug 23, 2017

@nreese Does this need to go into 6.x as well? It looks like it's only in master/6.0

@nreese
Copy link
Contributor Author

nreese commented Aug 23, 2017

@epixa yes, this needs to be merged with 6.x. I am having a problem with another PR, #13667, on 6.x and CI. My plan was to migrate this PR to 6.x once the other PR passes CI and gets merged

nreese added a commit to nreese/kibana that referenced this pull request Aug 24, 2017
* upgrade leaflet modules to 1.x latest

* fix css for leaflet controls

* update draw options so it is easier to see polygon when drawing

* fix chrome touch issues with closing polygon in leaflet draw

* use canvas renderer

* use leaflet-responsive-popup to avoid tooltip cutoff

* remove radius configuration from leaflet heatmap

* make blur a factor of radius. Set maxZoom to map zoom since new values are calculated per precision

* use _.get to avoid error, cannot read property of undefined

* add cluster size slider

* experiments with image differences

* onload not onLoad

* use canvas dimensions

* compare map canvas to stored PNG of map canvas

* remove pixelmatch from project dependecies

* fix broken test - rounding error

* add expected image tests for geohash layers shaded circles and geohash grids

* bump z-index of vis-spy

* update functional test expected data

* update to leaflet 1.2.0

* revert to leaflet 1.0.3 and update expected data set for map functional tests

* test geohash_layer heatmap in unit test

* update region_map functional test since it can not longer pluck map vectors from DOM

* update documentation
nreese added a commit that referenced this pull request Aug 24, 2017
* upgrade leaflet modules to 1.x latest

* fix css for leaflet controls

* update draw options so it is easier to see polygon when drawing

* fix chrome touch issues with closing polygon in leaflet draw

* use canvas renderer

* use leaflet-responsive-popup to avoid tooltip cutoff

* remove radius configuration from leaflet heatmap

* make blur a factor of radius. Set maxZoom to map zoom since new values are calculated per precision

* use _.get to avoid error, cannot read property of undefined

* add cluster size slider

* experiments with image differences

* onload not onLoad

* use canvas dimensions

* compare map canvas to stored PNG of map canvas

* remove pixelmatch from project dependecies

* fix broken test - rounding error

* add expected image tests for geohash layers shaded circles and geohash grids

* bump z-index of vis-spy

* update functional test expected data

* update to leaflet 1.2.0

* revert to leaflet 1.0.3 and update expected data set for map functional tests

* test geohash_layer heatmap in unit test

* update region_map functional test since it can not longer pluck map vectors from DOM

* update documentation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:Visualizations Generic visualization features (in case no more specific feature label is available) release_note:enhancement v6.0.0-beta2 v6.1.0 v7.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Tile Map tooltips near edges of map are cut off
4 participants