chart = addTooltips(
Plot.plot({
title: "NHK MUSIC EXPO 出演者の検索ボリューム推移を可視化してみる",
caption: "Google Trendsより徒然研究室(仮称)が2023年9月14日作成",
height: 675,
width: 1200,
marginTop: 50,
marginBottom: 0,
marginLeft: 220,
style: {
background: "rgb(250, 245, 240)",
fontSize: "13px",
color: "rgb(60, 60, 60)"
},
axis: null,
x: {
label: "放送時刻",
axis: "top",
round: true
},
y: {
domain: [-20, d3.max(traffic, (d) => d.value) / (overlap + 1)]
},
color: {
legend: true,
label: "検索ボリューム",
scheme: "purd",
style: { background: "rgb(250, 245, 240)" }
},
fy: {
domain: traffic.map((d) => d.keyword)
},
facet: {
data: traffic,
y: "keyword"
},
marks: [
Plot.areaY(traffic, {
x: "timestamp",
y: "value",
z: "keyword",
fill: "value",
fillOpacity: 0.85,
sort: "timestamp",
title: (d) => `時刻 ${d.timestamp}\検索ボリューム: ${d.value}`
}),
Plot.lineY(traffic, {
x: "timestamp",
y: "value",
z: "keyword",
strokeWidth: 1,
sort: "timestamp",
stroke: "black"
}),
Plot.text(
traffic,
Plot.selectFirst({
x: d3.min(traffic, (d) => d.timestamp),
text: "keyword",
dx: -4,
frameAnchor: "right",
fontFamily: "Noto Sans JP ExtraBold, sans-serif",
fontWeight: "bold",
fontSize: 20
})
)
]
})
)