Add hover tooltips to weather charts showing values at cursor position
This commit is contained in:
parent
8333ee3219
commit
22ccec7d06
1 changed files with 24 additions and 0 deletions
|
|
@ -135,6 +135,7 @@ const chartConfigs: Record<string, ChartConfig> = {
|
||||||
backgroundColor: "rgba(255, 0, 0, 0.1)",
|
backgroundColor: "rgba(255, 0, 0, 0.1)",
|
||||||
tension: 0.1,
|
tension: 0.1,
|
||||||
pointRadius: 0,
|
pointRadius: 0,
|
||||||
|
pointHoverRadius: 4,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: labels.dew_label || "Dew Point (°F)",
|
label: labels.dew_label || "Dew Point (°F)",
|
||||||
|
|
@ -143,6 +144,7 @@ const chartConfigs: Record<string, ChartConfig> = {
|
||||||
backgroundColor: "rgba(0, 0, 255, 0.1)",
|
backgroundColor: "rgba(0, 0, 255, 0.1)",
|
||||||
tension: 0.1,
|
tension: 0.1,
|
||||||
pointRadius: 0,
|
pointRadius: 0,
|
||||||
|
pointHoverRadius: 4,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
title: (labels) => labels.temp_title || "Temperature & Dew Point (°F)",
|
title: (labels) => labels.temp_title || "Temperature & Dew Point (°F)",
|
||||||
|
|
@ -158,6 +160,7 @@ const chartConfigs: Record<string, ChartConfig> = {
|
||||||
backgroundColor: "rgba(0, 255, 0, 0.1)",
|
backgroundColor: "rgba(0, 255, 0, 0.1)",
|
||||||
tension: 0.1,
|
tension: 0.1,
|
||||||
pointRadius: 0,
|
pointRadius: 0,
|
||||||
|
pointHoverRadius: 4,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
title: (labels) => labels.hum_title || "Humidity (%)",
|
title: (labels) => labels.hum_title || "Humidity (%)",
|
||||||
|
|
@ -174,6 +177,7 @@ const chartConfigs: Record<string, ChartConfig> = {
|
||||||
backgroundColor: "rgba(128, 0, 128, 0.1)",
|
backgroundColor: "rgba(128, 0, 128, 0.1)",
|
||||||
tension: 0.1,
|
tension: 0.1,
|
||||||
pointRadius: 0,
|
pointRadius: 0,
|
||||||
|
pointHoverRadius: 4,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
title: (labels) => labels.prs_title || "Barometric Pressure (mb)",
|
title: (labels) => labels.prs_title || "Barometric Pressure (mb)",
|
||||||
|
|
@ -189,6 +193,7 @@ const chartConfigs: Record<string, ChartConfig> = {
|
||||||
backgroundColor: "rgba(255, 165, 0, 0.1)",
|
backgroundColor: "rgba(255, 165, 0, 0.1)",
|
||||||
tension: 0.1,
|
tension: 0.1,
|
||||||
pointRadius: 0,
|
pointRadius: 0,
|
||||||
|
pointHoverRadius: 4,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: labels.gst_label || "Wind Gust (mph)",
|
label: labels.gst_label || "Wind Gust (mph)",
|
||||||
|
|
@ -197,6 +202,7 @@ const chartConfigs: Record<string, ChartConfig> = {
|
||||||
backgroundColor: "rgba(255, 0, 0, 0.1)",
|
backgroundColor: "rgba(255, 0, 0, 0.1)",
|
||||||
tension: 0.1,
|
tension: 0.1,
|
||||||
pointRadius: 0,
|
pointRadius: 0,
|
||||||
|
pointHoverRadius: 4,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
title: (labels) => labels.wnd_title || "Wind Speed & Gust (mph)",
|
title: (labels) => labels.wnd_title || "Wind Speed & Gust (mph)",
|
||||||
|
|
@ -235,6 +241,7 @@ const chartConfigs: Record<string, ChartConfig> = {
|
||||||
backgroundColor: "rgba(255, 215, 0, 0.1)",
|
backgroundColor: "rgba(255, 215, 0, 0.1)",
|
||||||
tension: 0.1,
|
tension: 0.1,
|
||||||
pointRadius: 0,
|
pointRadius: 0,
|
||||||
|
pointHoverRadius: 4,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
title: (labels) => labels.lum_title || "Solar Radiation (W/m²)",
|
title: (labels) => labels.lum_title || "Solar Radiation (W/m²)",
|
||||||
|
|
@ -295,6 +302,10 @@ function createChartHook(configKey: string): Hook {
|
||||||
adapters: { date: { locale: "en-GB" } },
|
adapters: { date: { locale: "en-GB" } },
|
||||||
responsive: true,
|
responsive: true,
|
||||||
maintainAspectRatio: false,
|
maintainAspectRatio: false,
|
||||||
|
interaction: {
|
||||||
|
mode: "index",
|
||||||
|
intersect: false,
|
||||||
|
},
|
||||||
plugins: {
|
plugins: {
|
||||||
title: {
|
title: {
|
||||||
display: true,
|
display: true,
|
||||||
|
|
@ -302,6 +313,19 @@ function createChartHook(configKey: string): Hook {
|
||||||
color: colors.text,
|
color: colors.text,
|
||||||
},
|
},
|
||||||
legend: { labels: { color: colors.text } },
|
legend: { labels: { color: colors.text } },
|
||||||
|
tooltip: {
|
||||||
|
enabled: true,
|
||||||
|
mode: "index",
|
||||||
|
intersect: false,
|
||||||
|
callbacks: {
|
||||||
|
label: (context: any) => {
|
||||||
|
const label = context.dataset.label || "";
|
||||||
|
const value = context.parsed.y;
|
||||||
|
if (value === null || value === undefined) return "";
|
||||||
|
return `${label}: ${Number.isInteger(value) ? value : value.toFixed(1)}`;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
scales: {
|
scales: {
|
||||||
x: {
|
x: {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue