3

我正在尝试将 .save_to_html() 函数用于 kepler.gl jupyter 笔记本地图。

这一切都在 jupyter 中运行良好,我可以使用定义的配置重新加载相同的地图。

出错的地方是我使用 save_to_html() 函数时。地图将保存为 html,但配置恢复为基本配置,在我自定义之前。

请帮忙!我喜欢开普勒,当我解决这个小问题时,它将是我们绝对的首选工具

谢谢

已尝试更改过滤器、颜色和点大小。这些都不起作用。

map_1 = KeplerGl(height=500, data={'data': df},config=config)
map_1

config  = map_1.config
config

map_1.save_to_html(data={'data_1': df}, 
file_name='privateers.html',config=config)


Config
{'version': 'v1',
 'config': {'visState': {'filters': [{'dataId': 'data',
     'id': 'x8t9c53mf',
     'name': 'time_update',
     'type': 'timeRange',
     'value': [1565687902187.5417, 1565775465282],
     'enlarged': True,
     'plotType': 'histogram',
     'yAxis': None},
    {'dataId': 'data',
     'id': 'biysqlu36',
     'name': 'user_id',
     'type': 'multiSelect',
     'value': ['HNc0SI3WsQfhOFRF2THnUEfmqJC3'],
     'enlarged': False,
     'plotType': 'histogram',
     'yAxis': None}],
   'layers': [{'id': 'ud6168',
     'type': 'point',
     'config': {'dataId': 'data',
      'label': 'Point',
      'color': [18, 147, 154],
      'columns': {'lat': 'lat', 'lng': 'lng', 'altitude': None},
      'isVisible': True,
      'visConfig': {'radius': 5,
       'fixedRadius': False,
       'opacity': 0.8,
       'outline': False,
       'thickness': 2,
       'strokeColor': None,
       'colorRange': {'name': 'Uber Viz Qualitative 1.2',
        'type': 'qualitative',
        'category': 'Uber',
        'colors': ['#12939A',
         '#DDB27C',
         '#88572C',
         '#FF991F',
         '#F15C17',
         '#223F9A'],
        'reversed': False},
       'strokeColorRange': {'name': 'Global Warming',
        'type': 'sequential',
        'category': 'Uber',
        'colors': ['#5A1846',
         '#900C3F',
         '#C70039',
         '#E3611C',
         '#F1920E',
         '#FFC300']},
       'radiusRange': [0, 50],
       'filled': True},
      'textLabel': [{'field': None,
        'color': [255, 255, 255],
        'size': 18,
        'offset': [0, 0],
        'anchor': 'start',
        'alignment': 'center'}]},
     'visualChannels': {'colorField': {'name': 'ride_id', 'type': 'string'},
      'colorScale': 'ordinal',
      'strokeColorField': None,
      'strokeColorScale': 'quantile',
      'sizeField': None,
      'sizeScale': 'linear'}},
    {'id': 'an8tbef',
     'type': 'point',
     'config': {'dataId': 'data',
      'label': 'previous',
      'color': [221, 178, 124],
      'columns': {'lat': 'previous_lat',
       'lng': 'previous_lng',
       'altitude': None},
      'isVisible': False,
      'visConfig': {'radius': 10,
       'fixedRadius': False,
       'opacity': 0.8,
       'outline': False,
       'thickness': 2,
       'strokeColor': None,
       'colorRange': {'name': 'Global Warming',
        'type': 'sequential',
        'category': 'Uber',
        'colors': ['#5A1846',
         '#900C3F',
         '#C70039',
         '#E3611C',
         '#F1920E',
         '#FFC300']},
       'strokeColorRange': {'name': 'Global Warming',
        'type': 'sequential',
        'category': 'Uber',
        'colors': ['#5A1846',
         '#900C3F',
         '#C70039',
         '#E3611C',
         '#F1920E',
         '#FFC300']},
       'radiusRange': [0, 50],
       'filled': True},
      'textLabel': [{'field': None,
        'color': [255, 255, 255],
        'size': 18,
        'offset': [0, 0],
        'anchor': 'start',
        'alignment': 'center'}]},
     'visualChannels': {'colorField': None,
      'colorScale': 'quantile',
      'strokeColorField': None,
      'strokeColorScale': 'quantile',
      'sizeField': None,
      'sizeScale': 'linear'}},
    {'id': 'ilpixu9',
     'type': 'arc',
     'config': {'dataId': 'data',
      'label': ' -> previous arc',
      'color': [146, 38, 198],
      'columns': {'lat0': 'lat',
       'lng0': 'lng',
       'lat1': 'previous_lat',
       'lng1': 'previous_lng'},
      'isVisible': True,
      'visConfig': {'opacity': 0.8,
       'thickness': 2,
       'colorRange': {'name': 'Global Warming',
        'type': 'sequential',
        'category': 'Uber',
        'colors': ['#5A1846',
         '#900C3F',
         '#C70039',
         '#E3611C',
         '#F1920E',
         '#FFC300']},
       'sizeRange': [0, 10],
       'targetColor': None},
      'textLabel': [{'field': None,
        'color': [255, 255, 255],
        'size': 18,
        'offset': [0, 0],
        'anchor': 'start',
        'alignment': 'center'}]},
     'visualChannels': {'colorField': None,
      'colorScale': 'quantile',
      'sizeField': None,
      'sizeScale': 'linear'}},
    {'id': 'inv52pp',
     'type': 'line',
     'config': {'dataId': 'data',
      'label': ' -> previous line',
      'color': [136, 87, 44],
      'columns': {'lat0': 'lat',
       'lng0': 'lng',
       'lat1': 'previous_lat',
       'lng1': 'previous_lng'},
      'isVisible': False,
      'visConfig': {'opacity': 0.8,
       'thickness': 2,
       'colorRange': {'name': 'Global Warming',
        'type': 'sequential',
        'category': 'Uber',
        'colors': ['#5A1846',
         '#900C3F',
         '#C70039',
         '#E3611C',
         '#F1920E',
         '#FFC300']},
       'sizeRange': [0, 10],
       'targetColor': None},
      'textLabel': [{'field': None,
        'color': [255, 255, 255],
        'size': 18,
        'offset': [0, 0],
        'anchor': 'start',
        'alignment': 'center'}]},
     'visualChannels': {'colorField': None,
      'colorScale': 'quantile',
      'sizeField': None,
      'sizeScale': 'linear'}}],
   'interactionConfig': {'tooltip': {'fieldsToShow': {'data': ['time_ride_start',
       'user_id',
       'ride_id']},
     'enabled': True},
    'brush': {'size': 0.5, 'enabled': False}},
   'layerBlending': 'normal',
   'splitMaps': []},
  'mapState': {'bearing': 0,
   'dragRotate': False,
   'latitude': 49.52565611453996,
   'longitude': 6.2730441822977845,
   'pitch': 0,
   'zoom': 9.244725880765998,
   'isSplit': False},
  'mapStyle': {'styleType': 'dark',
   'topLayerGroups': {},
   'visibleLayerGroups': {'label': True,
    'road': True,
    'border': False,
    'building': True,
    'water': True,
    'land': True,
    '3d building': False},
   'threeDBuildingColor': [9.665468314072013,
    17.18305478057247,
    31.1442867897876],
   'mapStyles': {}}}}

预期:在 Jupyter 小部件中完全配置的地图

未配置实际颜色和过滤器。地图的大小和位置是一起发送的,所以如果我将它存储在一个空白区域,当我打开 html 文件时,它会看到相同的字段

4

3 回答 3

1

在保存部分下的kepler.gl Jupyter 用户指南中

# this will save current map
map_1.save_to_html(file_name='first_map.html')

# this will save map with provided data and config
map_1.save_to_html(data={'data_1': df}, config=config, file_name='first_map.html')

# this will save map with the interaction panel disabled
map_1.save_to_html(file_name='first_map.html', read_only=True)

因此,如果配置参数不起作用,或者您在将地图配置设置为等于 config. 如果您设置,这将是固定的

map_1.save_to_html(data={'data_1': df}, 
file_name='privateers.html',config=map_1.config)
于 2020-01-23T18:32:40.050 回答
0

就我所见以及我如何解决类似问题而言,问题是,您 1) 在实例化地图时将“数据”键命名为不同于您告诉它保存在 HTML 中的键 2)。

  1. map_1 = KeplerGl(height=500, data={'data': df},config=config)
  2. map_1.save_to_html(data={'data_1': df}, file_name='privateers.html',config=config)

将两个键命名为相同,您的 HTML 文件将使用正确的配置。

于 2021-12-16T14:35:18.240 回答
0

我认为这是一个错误(或功能?)当您使用相同的单元格保存地图配置或仍未打印地图时发生。通常,只有在您真正打印出地图后,该配置才会存在。

于 2021-07-13T06:03:57.253 回答