Published
Edited
Apr 28, 2022
1 star
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
function dnorm(x, mean = 0, sd = 1) {
return 1 / sd * dnorm_standard((x - mean) / sd)
}
Insert cell
Insert cell
Insert cell
Insert cell
growth_size = values.length
Insert cell
Insert cell
Insert cell
Insert cell
curve_max = dnorm(growth_mean, growth_mean, growth_sd) * bin_width * growth_size
Insert cell
export2020 =to_billion(d3.sum(data, d => d.TradeValuePrevious))
Insert cell
export2021 = to_billion(d3.sum(data, d => d.TradeValue))
Insert cell
positive_percentage = values.filter(function(v) { return v > 0; }).length / values.length
Insert cell
values = d3.map(data, d=>to_billion(d.TradeValueGrowthValue))
Insert cell
data_old = d3.csvParse(await FileAttachment("Destinations-Growth-2019---2020---Click-to-Select-a-Country@2.csv").text(), d3.autoType)
Insert cell
data= d3.csvParse(await FileAttachment("Exports-Destinations-Growth-2021---2020----Click-to-Select-a-Country.csv").text(), d3.autoType).sort((a, b) => d3.descending(a.TradeValueGrowthValue, b.TradeValueGrowthValue))
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
line = d3.line()
.curve(d3.curveMonotoneX)
.x(d => x(d[0]))
.y(d => y(d[1]))
Insert cell
Insert cell
formatBillions(2)
Insert cell
Insert cell
formatBillions = d => `${formatNumber(d)}B`;
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
colors_lea_seydoux = ["#CF5F47","#1A1A1A","#F4EEE2"]
Insert cell
colors = colors_lea_seydoux
Insert cell
normalcolor = "#AE3039"
Insert cell
barcolor = colors[2]
Insert cell
textcolor = colors[1]
Insert cell
background = colors[0]
Insert cell
Insert cell
import { slider } from "@jashkenas/inputs"
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