{
    "$schema": "https://vega.github.io/schema/vega-lite/v4.json",
    "data": {
        "values": [
            {
                "Activity": "Sleeping",
                "Time": 8
            },
            {
                "Activity": "Eating",
                "Time": 2
            },
            {
                "Activity": "TV",
                "Time": 4
            },
            {
                "Activity": "Work",
                "Time": 8
            },
            {
                "Activity": "Exercise",
                "Time": 2
            }
        ]
    },
    "encoding": {
        "x": {
            "axis": {
                "title": "% of total Time"
            },
            "field": "PercentOfTotal",
            "type": "quantitative"
        },
        "y": {
            "field": "Activity",
            "type": "nominal"
        }
    },
    "height": {
        "step": 12
    },
    "mark": "bar",
    "transform": [
        {
            "joinaggregate": [
                {
                    "as": "TotalTime",
                    "field": "Time",
                    "op": "sum"
                }
            ]
        },
        {
            "as": "PercentOfTotal",
            "calculate": "datum.Time/datum.TotalTime * 100"
        }
    ]
}