Published
Edited
Apr 13, 2021
1 star
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
data = d3.csvParse(await FileAttachment("vgsales.csv").text(), function(d) {
return {
rank: d["Rank"],
name: d["Name"],
platform: d["Platform"],
year: d3.timeParse("%Y")(d["Year"]),
year_label: parseInt(d["Year"]),
genre: d["Genre"],
publisher: d["Publisher"],
na_sales: parseFloat(d["NA_Sales"]),
eu_sales: parseFloat(d["EU_Sales"]),
jp_sales: parseFloat(d["JP_Sales"]),
other_sales: parseFloat(d["Other_Sales"]),
global_sales: parseFloat(d["Global_Sales"])
};
});
Insert cell
Insert cell
data.sort(function (a, b) {
return a.year - b.year;
});
Insert cell
Insert cell
Insert cell
updated_data = {
data.forEach(function (arrayItem) {
if (arrayItem.publisher == "Nintendo")
arrayItem.popular = 2;
else if (arrayItem.publisher == "Sony Computer Entertainment")
arrayItem.popular = 3;
else if (arrayItem.publisher == "Microsoft Game Studios")
arrayItem.popular = 4;
else
arrayItem.popular = 0;
});
return data;
}
Insert cell
Insert cell
colors = ({
global_sales: "#4682b4",
na_sales: "#77d1ce",
eu_sales: "#dba6e3",
jp_sales: "#ffb95e"
});
Insert cell
axis_titles = ({
global_sales: "Global Sales (Millions)",
na_sales: "Global Sales from North America (Millions)",
eu_sales: "Global Sales from Europe (Millions)",
jp_sales: "Global Sales from Japan (Millions)"
});
Insert cell
sales_titles = ({
global_sales: "Global Sales (Millions)",
na_sales: "North America Sales (Millions)",
eu_sales: "Europe Sales (Millions)",
jp_sales: "Japan Sales (Millions)"
});
Insert cell
Insert cell
Insert cell
embed = require("vega-embed@4")
Insert cell
import { uniqueValid } from '@uwdata/data-utilities'
Insert cell
d3 = require("d3@6")
Insert cell
import {Select} from "@observablehq/inputs"
Insert cell
Inputs = require("@observablehq/inputs@0.7.17/dist/inputs.umd.min.js")
Insert cell
Range = Inputs.Range
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