charting/download.py
def json_to_chart(json_spec: str) -> alt.Chart:
    """
    take a json spec and produce a chart
    mostly needed for the weird work arounds needed for importing layer charts
    """
    di = json.loads(json_spec)
    if "layer" in di:
        layers = di["layer"]
        del di["layer"]
        del di["width"]
        chart = LayerChart.from_dict(
            {"config": di["config"], "layer": [], "datasets": di["datasets"]}
        )
        for n, l in enumerate(layers):
            di_copy = di.copy()
            di_copy.update(l)
            del di_copy["config"]
            del di_copy["$schema"]
            del di_copy["datasets"]
            del di_copy["width"]
            c = Chart.from_dict(di_copy)
            chart += c
    else:
        del di["width"]
        del di["config"]["view"]
        chart = Chart.from_dict(di)
    return chart

    take a json spec and produce a chart
    mostly needed for the weird work arounds needed for importing layer charts
    
take a json spec and produce a chart
mostly needed for the weird work arounds needed for importing layer charts
take a json spec and produce a chart mostly needed for the weird work arounds needed for importing layer charts
def json_to_chart(json_spec: str) -> alt.Chart:
    di = json.loads(json_spec)
    if "layer" in di:
        layers = di["layer"]
        del di["layer"]
        del di["width"]
        chart = LayerChart.from_dict(
            {"config": di["config"], "layer": [], "datasets": di["datasets"]}
        )
        for n, l in enumerate(layers):
            di_copy = di.copy()
            di_copy.update(l)
            del di_copy["config"]
            del di_copy["$schema"]
            del di_copy["datasets"]
            del di_copy["width"]
            c = Chart.from_dict(di_copy)
            chart += c
    else:
        del di["width"]
        del di["config"]["view"]
        chart = Chart.from_dict(di)
    return chart
def json_to_chart ( json_spec : str ) -> alt . Chart : di = json . loads ( json_spec ) if "layer" in di : layers = di [ "layer" ] del di [ "layer" ] del di [ "width" ] chart = LayerChart . from_dict ( { "config" : di [ "config" ] , "layer" : [ ] , "datasets" : di [ "datasets" ] } ) for n , l in enumerate ( layers ) : di_copy = di . copy ( ) di_copy . update ( l ) del di_copy [ "config" ] del di_copy [ "$schema" ] del di_copy [ "datasets" ] del di_copy [ "width" ] c = Chart . from_dict ( di_copy ) chart += c else : del di [ "width" ] del di [ "config" ] [ "view" ] chart = Chart . from_dict ( di ) return chart
take a json spec and produce a chart
mostly needed for the weird work arounds needed for importing layer charts
take a json spec and produce a chart mostly needed for the weird work arounds needed for importing layer charts
"""
    take a json spec and produce a chart
    mostly needed for the weird work arounds needed for importing layer charts
    """
json_spec
str