elastic / kibana

Your window into the Elastic Stack
https://www.elastic.co/products/kibana
Other
19.78k stars 8.19k forks source link

Map reloads when modifying Kibana time filter with Vega #140029

Open rriemvis opened 2 years ago

rriemvis commented 2 years ago

Kibana version: 8.4.0/8.4.1

Elasticsearch version: 8.4.0/8.4.1

Server OS version:

Browser version: Chrome 105.0.5195.102 64 bits

Browser OS version: Window 10 Pro 21H2

Original install method (e.g. download page, yum, from source, etc.):

Describe the bug:

When you include a map on a Vega custom script and you modify the Kibana Time filter with the function kibanaSetTimeFilter(...), the map tiles are reloaded at every call of this function. This is very annoying as it looks like a page reload and the map-scale, map-center is not modified at all.

Steps to reproduce:

The following minimal script generates the described behavior:

{
  "$schema": "https://vega.github.io/schema/vega/v5.json",
  "title": "map reloaded when timefilter updated bug",
  "config": {
    "kibana": {
      "restoreSignalValuesOnRefresh": true
      "type": "map", 
      "latitude": 0, 
      "longitude": 0, 
      "zoom": 5,

      "mapStyle": true,

      // May either be: "road_map", "road_map_desaturated", "dark_map".
      // If 'emsTileServiceId' is 'undefined', it falls back to the auto-switch-dark-light behavior.
      "emsTileServiceId": "road_map",

      // default 0
      "minZoom": 0,

      // defaults to the maximum for the given style,
      // or 25 when base is disabled
      "maxZoom": 20,

      // Defaults to 'true', shows +/- buttons to zoom in/out
      "zoomControl": false,

      // Defaults to 'false', disables mouse wheel zoom. If set to
      // 'true', map may zoom unexpectedly while scrolling dashboard
      "scrollWheelZoom": true,

      // When false, repaints on each move frame.
      // Makes the graph slower when moving the map
      "delayRepaint": true // default true
    }
  },

  "signals": [
    {
      "name": "filter_date",
      "value": [1640995200000,1640995210000],
      "description": "start and end date retrieved from the current Kibana filter in epoch_ms",
            "on": [
                {
          "events": {"type": "timer", "throttle": 10000},
          "update": "[filter_date[1],filter_date[1]+10000]"
        }
      ]
    },
    {
      "name": "update_time_filter",
      "description": "update the Kibana time filter when filter_date is updated",
      "on": [
        {
          "events": {"signal": "filter_date"},
          "update": "kibanaSetTimeFilter(filter_date[0],filter_date[1])"
        }
      ]
    }
  ]
}

Expected behavior:

No effect on the map loading when the kibana time filter is called.

Screenshots (if relevant):

Errors in browser console (if relevant):

Provide logs and/or server output (if relevant):

Any additional context:

elasticmachine commented 2 years ago

Pinging @elastic/kibana-vis-editors @elastic/kibana-vis-editors-external (Team:VisEditors)

rriemvis commented 2 years ago

@flash1293 : in my opinion this is still a bug: why should a map reload occur when you update the Kibana time filter from within the Vega script (while not changing any map settings/signals)? This behavior is not logical and prevents dynamic updates in combination with a map. Correct functioning of this allows for live updates of data on a map dashboard for example.

flash1293 commented 2 years ago

@rriemvis I understand how the behavior you describe would be an improvement, however I checked an old version of Kibana and it seems like vega maps never behaved any differently than they do right now - it's on the edge between enhancement and bug for me.

Anyway, the categorization doesn't matter too much. I will raise this with the team and get back to you shortly. Unfortunately the enhancement isn't super simple to implement based on how the code is structured, but I agree that it would be a much better user experience to just update the data and not the whole map instance.