Public
Edited
May 15
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
portfolioData = d3.csv("https://docs.google.com/spreadsheets/d/e/2PACX-1vQSz2gGUW3Sgq0hrcpaKM3ToNgEGImWgwJthfp3b9OUmxiEcEN6kMZygz1HZuq1cbbPcxcWXGUicurY/pub?gid=0&single=true&output=csv")
Insert cell
Insert cell
Insert cell
Insert cell
render({
mark: "arc",
data: { values: portfolioData },
transform: [
{ calculate: "datum.Shares*datum.Price", as: "Total Value" }
],
encoding: {
row: { field: "Date", type: "T" },
column: { field: "Investor", type: "N" },
color: { field: "Symbol", type: "N" },
theta: { field: "Total Value", type: "Q" },
tooltip: [
{ field: "Symbol", type: "N" },
{ field: "Price", type: "Q" },
{ field: "Shares", type: "Q" },
{ field: "Total Value", type: "Q" }
]
},
width: 150,
height: 200
})
Insert cell
Insert cell
render({
mark: "bar",
data: { values: portfolioData },
transform: [
{ calculate: "datum.Shares * datum.Price", as: "Total Value" }
],
encoding: {
x: { field: "Investor", type: "N" },
y: { aggregate: "sum", field: "Total Value", type: "Q" },
color: { field: "Symbol", type: "N" },
tooltip: [
{ field: "Symbol", type: "N" },
{ field: "Price", type: "Q" },
{ field: "Shares", type: "Q" },
{ field: "Total Value", type: "Q" }
]
}
})
Insert cell
Insert cell
render({
mark: { type: "line", point: true },
data: { values: portfolioData },
transform: [
{ calculate: "datum.Shares * datum.Price", as: "Total Value" }
],
encoding: {
x: { field: "Date", type: "T" },
y: { aggregate: "sum", field: "Total Value", type: "Q" },
column: { field: "Investor", type: "N" },
tooltip: [
{ field: "Date", type: "T" },
{ aggregate: "sum", field: "Total Value", type: "Q" }
],
},
width: 190,
height: 200
})
Insert cell
Insert cell
render({
mark: { type: "line", point: true },
data: { values: portfolioData },
transform: [
{ calculate: "datum.Shares * datum.Price", as: "Total Value" }
],
encoding: {
x: { field: "Date", type: "T" },
y: { aggregate: "sum", field: "Total Value", type: "Q" },
color: { field: "Investor", type: "N" }, // Add this to distinguish investors
tooltip: [
{ field: "Date", type: "T" },
{ aggregate: "sum", field: "Total Value", type: "Q" },
{ field: "Investor", type: "N" } // Add Investor to tooltip
]
},
width: 600,
height: 400
})

Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
render({
mark: { type: "line", point: { filled: true, size: 50 } }, // Bigger points
data: { values: portfolioData },
transform: [
{ calculate: "datum.Shares * datum.Price", as: "Total Value" }
],
encoding: {
x: {
field: "Date",
type: "temporal",
axis: {
title: "Date",
titleFontSize: 16,
labelFontSize: 12
}
},
y: {
aggregate: "sum",
field: "Total Value",
type: "quantitative",
axis: {
title: "Total Portfolio Value",
titleFontSize: 16,
labelFontSize: 12
}
},
color: {
field: "Investor",
type: "nominal",
scale: { scheme: "tableau10" }, // Visually pleasant color scheme
legend: {
title: "Investor",
titleFontSize: 14,
labelFontSize: 12
}
},
tooltip: [
{ field: "Date", type: "temporal" },
{ aggregate: "sum", field: "Total Value", type: "quantitative", format: "$,.2f" },
{ field: "Investor", type: "nominal" }
]
},
config: {
axis: {
grid: false
},
line: {
strokeWidth: 2
},
view: {
stroke: "transparent"
}
},
width: 700,
height: 400
})

Insert cell
Insert cell
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more