chart = addTooltips(
Plot.plot({
title: "NHK紅白歌合戦2023 生放送中の X投稿数の推移",
caption: "Xデータより徒然研究室(仮称)が2023年12月31日作成。",
height: 1030,
width: 900,
marginTop: 50,
marginBottom: 0,
marginLeft: 185,
style: {
background: "#FBFAF5",
fontSize: "12px",
color: "rgb(60, 60, 60)"
},
axis: null,
x: {
label: "検索日",
axis: "top",
round: true
},
y: {
domain: [-20, d3.max(nhk_kouhaku, (d) => d.Tweet_Count) / (overlap + 1)]
},
color: {
legend: true,
label: "15分あたりの投稿数",
scheme: "Turbo",
style: { width: 180, background: "#FBFAF5" }
},
fy: {
domain: nhk_kouhaku.map((d) => d.query)
},
facet: {
data: nhk_kouhaku,
y: "query"
},
marks: [
Plot.areaY(nhk_kouhaku, {
x: "Minute_Timestamp",
y: "Tweet_Count",
z: "query",
fill: "Tweet_Count",
fillOpacity: 0.65,
sort: "Minute_Timestamp",
curve: "catmull-rom",
title: (d) =>
`${d.query} 時刻 ${d.Minute_Timestamp} 検索ボリューム: ${d.Tweet_Count}`
}),
Plot.lineY(nhk_kouhaku, {
x: "Minute_Timestamp",
y: "Tweet_Count",
z: "query",
curve: "catmull-rom",
strokeWidth: 0.5,
sort: "Minute_Timestamp",
stroke: "black"
}),
Plot.text(
nhk_kouhaku,
Plot.selectFirst({
x: d3.min(nhk_kouhaku, (d) => d.Minute_Timestamp),
text: "query",
dx: -5,
dy: 0,
frameAnchor: "right",
fontFamily: "Noto Sans JP ExtraBold, sans-serif",
fontWeight: "bold",
fontSize: 15,
fill: "rgba(0, 0, 0, 0.7)"
})
)
]
})
)