chart = addTooltips(
Plot.plot({
caption: "Xデータより徒然研究室(仮称)が2023年12月25日作成。",
height: 600,
width: 1200,
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(traffic, (d) => d.Tweet_Count) / (overlap + 1)]
},
color: {
legend: true,
label: "15分あたりの検索ボリューム",
scheme: "Turbo",
style: { width: 180, background: "#FBFAF5" }
},
fy: {
domain: traffic.map((d) => d.query)
},
facet: {
data: traffic,
y: "query"
},
marks: [
Plot.areaY(traffic, {
x: "Minute_Timestamp",
y: "Tweet_Count",
z: "query",
fill: "Tweet_Count",
fillOpacity: 0.65,
sort: "Minute_Timestamp",
title: (d) =>
`${d.query} 時刻 ${d.Minute_Timestamp} 検索ボリューム: ${d.Tweet_Count}`
}),
Plot.lineY(traffic, {
x: "Minute_Timestamp",
y: "Tweet_Count",
z: "query",
curve: "catmull-rom",
strokeWidth: 0.5,
sort: "Minute_Timestamp",
stroke: "black"
}),
Plot.text(
traffic,
Plot.selectFirst({
x: d3.min(traffic, (d) => d.Minute_Timestamp),
text: "query",
dx: -5,
dy: 0,
frameAnchor: "right",
fontFamily: "Noto Sans JP ExtraBold, sans-serif",
fontWeight: "bold",
fontSize: 22,
fill: "rgba(0, 0, 0, 0.7)"
})
)
]
})
)