var yourVlSpec = {
"$schema": "https://vega.github.io/schema/vega-lite/v5.json",
"description": "A simple bar chart with embedded data.",
"data": {
"values": [{
"index": 0.03,
"program": "Deliciousness"
},
{
"index": 0.43,
"program": "Reno 911!"
},
{
"index": 0.07,
"program": "Curious Life and Death of"
},
{
"index": 0.01,
"program": "True Life"
},
{
"index": 4.21,
"program": "Two and a Half Men"
},
{
"index": 0.06,
"program": "How Far is Tattoo Far"
},
{
"index": 0.39,
"program": "Cheaters"
},
{
"index": 4.72,
"program": "Bar Rescue"
},
{
"index": 0.81,
"program": "Key & Peele"
},
{
"index": 0.25,
"program": "Drunk History"
},
{
"index": 1.32,
"program": "Tosh.O"
},
{
"index": 0.11,
"program": "Revenge Prank"
},
{
"index": 4.88,
"program": "Workaholics"
},
{
"index": 0.04,
"program": "My Wife and Kids"
},
{
"index": 0.05,
"program": "World of Weapons"
},
{
"index": 0.03,
"program": "Roseanne"
},
{
"index": 1.98,
"program": "Everybody Loves Raymond"
},
{
"index": 1.2,
"program": "Aerial America"
}
]
},
"height": {
"step": 17
},
"title": "Gold",
"encoding": {
"y": {
"field": "program",
"type": "ordinal",
"sort": "-x"
},
"x": {
"aggregate": "sum",
"field": "index",
"title": "Gold",
"axis": null
}
},
"layer": [{
"mark": "bar",
"encoding": {
"color": {
"field": "index",
"scale": {
"range": ["red", "yellow", "green"],
"type": "linear"
},
"legend": null
}
}
},
{
"mark": {
"type": "text",
"align": "left",
"baseline": "middle",
"dx": 3
},
"encoding": {
"text": {
"field": "index",
"type": "quantitative"
}
}
}
]
};
vegaEmbed("#vis", yourVlSpec);
<script src="https://cdn.jsdelivr.net/combine/npm/vega@5.20.2,npm/vega-lite@5.0.0,npm/vega-embed@6.17.0"></script>
<body>
<div id="vis"></div>
</body>