Published
Edited
Nov 7, 2019
1 fork
Insert cell
md`# IAT355 data`
Insert cell
d3 = require('d3@5')
Insert cell
VegaLite = require('vega-embed@5')
Insert cell
econ = d3.csv("https://www.sfu.ca/~ridgez/IAT355_data/top%207%20plus%20canada%20partner%20plus%20world.txt", d => {
// return d;
if (d["Period Code"] !== "A") return undefined;
// if (d["Product/Sector"].toLowerCase().includes("total")) return undefined;
if (!d["Product/Sector"].includes("Total merchandise")) return undefined;
return {
IndCat: d["Indicator Category"],
Ind: d["Indicator"],
RepEcon: d["Reporting Economy"],
ParEcon: d["Partner Economy"],
Year: d["Year"],
Value: d["Value"],
Sector: d["Product/Sector"]
};
})
Insert cell
econOnlyWorld = econ.filter(d => d.ParEcon === "World");
Insert cell
VegaLite({
data: {values: econOnlyWorld},
mark: "line",
encoding: {
x: {field: "Year", type: "nominal", sort: {encoding: "x", order: "assending"}},
y: {aggregate: "sum", field: "Value"},
color: {field: "RepEcon", type: "nominal"},
}
})
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