Public
Edited
May 12
Insert cell
Insert cell
rawData = await d3.csvParse(await FileAttachment("Negative Thoughts Dataset 3.csv").text());
Insert cell
thoughtsData = rawData.map((d, i) => ({
index: i,
Time: d.Time,
Emotion: d.Emotion,
Intensity: +d.Intensity,
Description: d.Description,
Insights: d.Insights
}));
Insert cell
maxIntensity = Math.max(...thoughtsData.map(d => d.Intensity));
Insert cell
indices = thoughtsData.map(d => d.index);
Insert cell
segments2 = thoughtsData.slice(1).map((d, i) => ({
x1: thoughtsData[i].Time,
y1: thoughtsData[i].Intensity,
x2: d.Time,
y2: d.Intensity,
Emotion: d.Emotion
}));
Insert cell
timeOrder = thoughtsData.map(d => d.Time);
Insert cell
Plot.plot({
marginLeft: 60,
marginBottom: 80,
title: "Negative Thoughts on 4/28 and some of 4/29",
x: {
label: "Time",
type: "band",
domain: timeOrder,
tickRotate: -45
},
y: {
label: "Intensity",
domain: [0, maxIntensity]
},
color: {
legend: true,
label: "Emotion"
},
marks: [
Plot.link(segments2, {x1: "x1", y1: "y1", x2: "x2", y2: "y2", stroke: "Emotion"}),
Plot.dot(thoughtsData, {
x: "Time",
y: "Intensity",
fill: "Emotion",
r: 5,
title: d => `Description: ${d.Description}\n\nPost-Game Analysis: ${d.Insights}`,
tip: true
})
]
});
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