예제 #1
0
파일: views.py 프로젝트: krishnatray/dtale
    def map_data(map_type, loc_mode, loc, lat, lon, map_val, scope, style,
                 proj, group, pathname):
        data_id = get_data_id(pathname)
        map_type = map_type or 'choropleth'
        if map_type == 'choropleth':
            map_data = dict(map_type=map_type,
                            loc_mode=loc_mode,
                            loc=loc,
                            map_val=map_val)
        elif map_type == 'mapbox':
            map_data = dict(map_type=map_type,
                            lat=lat,
                            lon=lon,
                            map_val=map_val,
                            mapbox_style=style)
        else:
            map_data = dict(map_type=map_type,
                            lat=lat,
                            lon=lon,
                            map_val=map_val,
                            scope=scope,
                            proj=proj)

        if group is not None:
            map_data['map_group'] = group
        df = global_state.get_data(data_id)
        loc_options, lat_options, lon_options, map_val_options = build_map_options(
            df, type=map_type, loc=loc, lat=lat, lon=lon, map_val=map_val)
        choro_style = {} if map_type == 'choropleth' else {'display': 'none'}
        coord_style = {} if map_type in ['scattergeo', 'mapbox'] else {
            'display': 'none'
        }
        scatt_style = {} if map_type == 'scattergeo' else {'display': 'none'}
        mapbox_style = {} if map_type == 'mapbox' else {'display': 'none'}
        proj_hover_style = {
            'display': 'none'
        } if proj is None else dict(borderBottom='none')
        proj_hopver_children = build_proj_hover_children(proj)
        loc_mode_hover_style = {
            'display': 'none'
        } if loc_mode is None else dict(borderBottom='none')
        loc_mode_children = build_loc_mode_hover_children(loc_mode)
        return (map_data, loc_options, lat_options, lon_options,
                map_val_options, choro_style, choro_style, coord_style,
                coord_style, scatt_style, mapbox_style, scatt_style,
                proj_hover_style, proj_hopver_children, loc_mode_hover_style,
                loc_mode_children)
예제 #2
0
파일: views.py 프로젝트: nogtini/dtale
 def map_data(map_type, loc_mode, loc, lat, lon, map_val, scope, proj,
              pathname):
     data_id = get_data_id(pathname)
     map_type = map_type or 'choropleth'
     if map_type == 'choropleth':
         map_data = dict(map_type=map_type,
                         loc_mode=loc_mode,
                         loc=loc,
                         map_val=map_val)
     else:
         map_data = dict(map_type=map_type,
                         lat=lat,
                         lon=lon,
                         map_val=map_val,
                         scope=scope,
                         proj=proj)
     df = global_state.get_data(data_id)
     loc_options, lat_options, lon_options, map_val_options = build_map_options(
         df, type=map_type, loc=loc, lat=lat, lon=lon, map_val=map_val)
     choro_style = {} if map_type == 'choropleth' else {'display': 'none'}
     scatt_style = {} if map_type == 'scattergeo' else {'display': 'none'}
     return (map_data, loc_options, lat_options, lon_options,
             map_val_options, choro_style, choro_style, scatt_style,
             scatt_style, scatt_style, scatt_style)
예제 #3
0
    def map_data(
        map_type, loc_mode, loc, lat, lon, map_val, scope, style, proj, group, pathname
    ):
        data_id = get_data_id(pathname)
        map_type = map_type or "choropleth"
        if map_type == "choropleth":
            map_data = dict(
                map_type=map_type, loc_mode=loc_mode, loc=loc, map_val=map_val
            )
        elif map_type == "mapbox":
            map_data = dict(
                map_type=map_type, lat=lat, lon=lon, map_val=map_val, mapbox_style=style
            )
        else:
            map_data = dict(
                map_type=map_type,
                lat=lat,
                lon=lon,
                map_val=map_val,
                scope=scope,
                proj=proj,
            )

        if group is not None:
            map_data["map_group"] = group
        df = global_state.get_data(data_id)
        loc_options, lat_options, lon_options, map_val_options = build_map_options(
            df, type=map_type, loc=loc, lat=lat, lon=lon, map_val=map_val
        )
        choro_style = {} if map_type == "choropleth" else {"display": "none"}
        coord_style = (
            {} if map_type in ["scattergeo", "mapbox"] else {"display": "none"}
        )
        scatt_style = {} if map_type == "scattergeo" else {"display": "none"}
        mapbox_style = {} if map_type == "mapbox" else {"display": "none"}
        proj_hover_style = (
            {"display": "none"} if proj is None else dict(borderBottom="none")
        )
        proj_hopver_children = build_proj_hover_children(proj)
        loc_mode_hover_style = (
            {"display": "none"} if loc_mode is None else dict(borderBottom="none")
        )
        loc_mode_children = build_loc_mode_hover_children(loc_mode)
        return (
            map_data,
            loc_options,
            lat_options,
            lon_options,
            map_val_options,
            choro_style,
            choro_style,
            coord_style,
            coord_style,
            scatt_style,
            mapbox_style,
            scatt_style,
            proj_hover_style,
            proj_hopver_children,
            loc_mode_hover_style,
            loc_mode_children,
        )