vegaEmbed({
width:"2000",
height:"1000",
data: { values: biopic_count },
transform: [
{calculate: "datum.sex_count == 2 ? 'Female Actor' : 'Male Actor' ", as: "gender" },
{calculate: "datum.sex_count == 2 ? -datum.count : datum.count", as: "signed_people"}
],
mark: {type:"bar", tooltip: true},
encoding: {
y: {
field: "year_release",
axis: null, sort: "ascending"
},
x: {
aggregate: "sum", field: "signed_people",
title: "population",
axis: {format: "s"},
stack: true
},
color: {
field: "gender",
scale: {"range": ["#675193", "#ca8861"]},
legend: {"orient": "top", "title": null}
},
tooltip: [
{ field: "subject", type: "nominal" },
{ field: "lead_actor_actress", type: "nominal" },
{ field: "year_release", type: "nominal" },
{ field: "title", type: "nominal" }
]
},
config: {
view: {stroke: null},
axis: {grid: false}
},
layer: [{
mark: "bar"
}, {
mark: {
type: "text",
align: "left",
baseline: "middle",
},
encoding: {
text: {aggregate: "sum", field: "signed_people", type: "quantitative"}
}
},
{
mark: {
type: "text",
align: "right",
baseline: "middle",
},
encoding: {
text: {aggregate: "sum", field: "signed_people", type: "quantitative"}
}
}
]
})