Public
Edited
Apr 25, 2023
Importers
Insert cell
# Vega Charts
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
std_stacked_chart2 = function (data) {
return vegalite({
$schema: "https://vega.github.io/schema/vega-lite/v5.json",
data: { values: data },
mark: "bar",
transform: [
{
calculate: "toNumber(datum.count)",
as: "Counts"
}
],
encoding: {
x: {
field: "category",
type: "ordinal",
title: "category",
sort: ["baseline", "organic", "improved"]
},
y: {
aggregate: "sum",
type: "quantitative",
field: "count",
title: "Total number of DOIs"
},
color: {
field: "segmentation",
type: "nominal",
legend: {
labelExpr:
"{'has_subject': 'Includes Subject', 'difference': 'Subjec Metadata is abset'}[datum.label]"
},
scale: {
domain: ["has_subject", "difference"],
range: ["#e7ba52", "#c7c7c7"]
},
title: "State"
}
}
});
}
Insert cell
Insert cell
Insert cell
vegaEmbed = require("vega-embed@6")
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more