chart = addTooltips(
Plot.plot({
caption:
"Google Trendsより徒然研究室(仮称)が2023年9月24日作成。出場歌手はKeiさん@Kei_radioの23年9月13日付ブログの予想を使用させていただいています。",
height: 1030,
width: 900,
marginTop: 50,
marginBottom: 0,
marginLeft: 185,
style: {
background: "#FBFAF5",
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: "Turbo",
style: { width: 180, background: "#FBFAF5" }
},
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.65,
sort: "timestamp",
title: (d) =>
`${d.keyword} 時刻 ${d.timestamp} 検索ボリューム: ${d.value}`
}),
Plot.lineY(traffic, {
x: "timestamp",
y: "value",
z: "keyword",
curve: "catmull-rom",
strokeWidth: 1,
sort: "timestamp",
stroke: "black"
}),
Plot.text(
traffic,
Plot.selectFirst({
x: d3.min(traffic, (d) => d.timestamp),
text: "keyword",
dx: -5,
dy: -5,
frameAnchor: "right",
fontFamily: "Noto Sans JP ExtraBold, sans-serif",
fontWeight: "bold",
fontSize: 15,
fill: "rgba(0, 0, 0, 0.7)"
})
)
]
})
)