philippjfr / panel-graphic-walker

A project providing a Graphic Walker Pane for use with HoloViz Panel.
2 stars 1 forks source link

Cannot use exported configuration #7

Open MarcSkovMadsen opened 1 day ago

MarcSkovMadsen commented 1 day ago

I would expect to be able to serve

import pandas as pd
import panel as pn

from panel_gwalker import GraphicWalker

pn.extension(sizing_mode="stretch_width")

LOGO = "https://kanaries.net/_next/static/media/kanaries-logo.0a9eb041.png"

df = pd.read_csv(
    "https://datasets.holoviz.org/windturbines/v1/windturbines.csv.gz", nrows=10000
)

walker = GraphicWalker(df, sizing_mode="stretch_both", styles={"border": "1px solid yellow"})

pn.template.FastListTemplate(
    logo=LOGO,
    title="Panel Graphic Walker",
    main=[walker],
    main_layout=None,
).servable()

Configure the walker:

image

Export the configuration

image

and use it

import pandas as pd
import panel as pn

from panel_gwalker import GraphicWalker

pn.extension(sizing_mode="stretch_width")

LOGO = "https://kanaries.net/_next/static/media/kanaries-logo.0a9eb041.png"

df = pd.read_csv(
    "https://datasets.holoviz.org/windturbines/v1/windturbines.csv.gz", nrows=10000
)

config = {"config":{"defaultAggregated":True,"geoms":["auto"],"coordSystem":"generic","limit":-1},"encodings":{"dimensions":[{"fid":"faa_ors","name":"faa_ors","basename":"faa_ors","semanticType":"nominal","analyticType":"dimension"},{"fid":"faa_asn","name":"faa_asn","basename":"faa_asn","semanticType":"nominal","analyticType":"dimension"},{"fid":"t_state","name":"t_state","basename":"t_state","semanticType":"nominal","analyticType":"dimension"},{"fid":"t_county","name":"t_county","basename":"t_county","semanticType":"nominal","analyticType":"dimension"},{"fid":"p_name","name":"p_name","basename":"p_name","semanticType":"nominal","analyticType":"dimension"},{"fid":"t_manu","name":"t_manu","basename":"t_manu","semanticType":"nominal","analyticType":"dimension"},{"fid":"t_model","name":"t_model","basename":"t_model","semanticType":"nominal","analyticType":"dimension"},{"fid":"retrofit","name":"retrofit","basename":"retrofit","semanticType":"nominal","analyticType":"dimension"},{"fid":"t_conf_atr","name":"t_conf_atr","basename":"t_conf_atr","semanticType":"ordinal","analyticType":"dimension"},{"fid":"t_conf_loc","name":"t_conf_loc","basename":"t_conf_loc","semanticType":"ordinal","analyticType":"dimension"},{"fid":"t_img_date","name":"t_img_date","basename":"t_img_date","semanticType":"nominal","analyticType":"dimension"},{"fid":"t_img_srce","name":"t_img_srce","basename":"t_img_srce","semanticType":"nominal","analyticType":"dimension"},{"fid":"gw_mea_key_fid","name":"Measure names","analyticType":"dimension","semanticType":"nominal"}],"measures":[{"fid":"case_id","name":"case_id","basename":"case_id","analyticType":"measure","semanticType":"quantitative","aggName":"sum"},{"fid":"usgs_pr_id","name":"usgs_pr_id","basename":"usgs_pr_id","analyticType":"measure","semanticType":"quantitative","aggName":"sum"},{"fid":"eia_id","name":"eia_id","basename":"eia_id","analyticType":"measure","semanticType":"quantitative","aggName":"sum"},{"fid":"t_fips","name":"t_fips","basename":"t_fips","analyticType":"measure","semanticType":"quantitative","aggName":"sum"},{"fid":"p_year","name":"p_year","basename":"p_year","analyticType":"measure","semanticType":"quantitative","aggName":"sum"},{"fid":"p_tnum","name":"p_tnum","basename":"p_tnum","analyticType":"measure","semanticType":"quantitative","aggName":"sum"},{"fid":"p_cap","name":"p_cap","basename":"p_cap","analyticType":"measure","semanticType":"quantitative","aggName":"sum"},{"fid":"t_cap","name":"t_cap","basename":"t_cap","analyticType":"measure","semanticType":"quantitative","aggName":"sum"},{"fid":"t_hh","name":"t_hh","basename":"t_hh","analyticType":"measure","semanticType":"quantitative","aggName":"sum"},{"fid":"t_rd","name":"t_rd","basename":"t_rd","analyticType":"measure","semanticType":"quantitative","aggName":"sum"},{"fid":"t_rsa","name":"t_rsa","basename":"t_rsa","analyticType":"measure","semanticType":"quantitative","aggName":"sum"},{"fid":"t_ttlh","name":"t_ttlh","basename":"t_ttlh","analyticType":"measure","semanticType":"quantitative","aggName":"sum"},{"fid":"retrofit_year","name":"retrofit_year","basename":"retrofit_year","analyticType":"measure","semanticType":"ordinal","aggName":"sum"},{"fid":"xlong","name":"xlong","basename":"xlong","analyticType":"measure","semanticType":"quantitative","aggName":"sum"},{"fid":"ylat","name":"ylat","basename":"ylat","analyticType":"measure","semanticType":"quantitative","aggName":"sum"},{"fid":"easting","name":"easting","basename":"easting","analyticType":"measure","semanticType":"quantitative","aggName":"sum"},{"fid":"northing","name":"northing","basename":"northing","analyticType":"measure","semanticType":"quantitative","aggName":"sum"},{"fid":"gw_count_fid","name":"Row count","analyticType":"measure","semanticType":"quantitative","aggName":"sum","computed":True,"expression":{"op":"one","params":[],"as":"gw_count_fid"}},{"fid":"gw_mea_val_fid","name":"Measure values","analyticType":"measure","semanticType":"quantitative","aggName":"sum"}],"rows":[],"columns":[{"fid":"t_manu","name":"t_manu","basename":"t_manu","semanticType":"nominal","analyticType":"dimension"}],"color":[],"opacity":[],"size":[],"shape":[],"radius":[],"theta":[],"longitude":[],"latitude":[],"geoId":[],"details":[],"filters":[],"text":[]},"layout":{"showActions":False,"showTableSummary":False,"stack":"stack","interactiveScale":False,"zeroScale":True,"size":{"mode":"auto","width":320,"height":200},"format":{},"geoKey":"name","resolve":{"x":False,"y":False,"color":False,"opacity":False,"shape":False,"size":False}},"visId":"gw_wG2i","name":"Chart 1"}

walker = GraphicWalker(df, config=config, sizing_mode="stretch_both", styles={"border": "1px solid yellow"})

pn.template.FastListTemplate(
    logo=LOGO,
    title="Panel Graphic Walker",
    main=[walker],
    main_layout=None,
).servable()

But it does not seem to work as I don't get the configuration exported:

image

Also related to https://github.com/philippjfr/panel-graphic-walker/issues/4.

MarcSkovMadsen commented 9 hours ago

PygWalker allows saving and using a spec:

https://github.com/Kanaries/pygwalker#better-practices

image

image

image