chart = {
const separate = options.includes("Separate"),
order = options.includes("Order"),
align = options.includes("Align");
const y = vl
.y()
.fieldN("Country Name")
.sort(order ? vl.fieldQ(selectedSeries).order("descending") : "y");
const base = vl
.mark({ type: separate ? "bar" : "tick", tooltip: { data: true } })
.data(filteredData)
.encode(
align
? vl.x().fieldQ(selectedSeries).axis({ orient: "top" })
: vl.x().fieldQ("latitude").axis(null),
align ? null : vl.x2().fieldQ("latitudePlusGdp"),
separate ? y : null
);
const withText = vl.layer(
base,
base
.markText({ align: "left", dx: 2, size: 14 })
.encode(vl.text().fieldQ(selectedSeries).format("$0.2s"))
);
return (separate ? withText : base)
.config({
axis: {
labelFontSize: 12
}
})
.width(300)
.render();
}