mirror of
https://git.ianrenton.com/ian/spothole.git
synced 2026-04-29 18:25:58 +00:00
Kp forecast axis swap on mobile
This commit is contained in:
@@ -150,6 +150,25 @@ function renderKIndexForecast(data) {
|
||||
|
||||
if (kpChart) { kpChart.destroy(); }
|
||||
|
||||
const isMobile = window.innerWidth < 768;
|
||||
const kpAxisTicks = {
|
||||
stepSize: 1,
|
||||
color: textColor,
|
||||
// Include geomagnetic storm levels (Gx) alongside the Kp index
|
||||
callback: v => v > 4 ? `(G${v - 4}) ${v}` : String(v),
|
||||
};
|
||||
const kpAxis = {
|
||||
min: 0,
|
||||
max: 9,
|
||||
title: { display: true, text: 'Kp', color: textColor },
|
||||
ticks: kpAxisTicks,
|
||||
grid: { color: gridColor },
|
||||
};
|
||||
const timeAxis = {
|
||||
ticks: { color: textColor, maxRotation: 45, minRotation: 0 },
|
||||
grid: { color: gridColor },
|
||||
};
|
||||
|
||||
kpChart = new Chart(document.getElementById('forecast-kp-chart'), {
|
||||
type: 'bar',
|
||||
data: {
|
||||
@@ -162,7 +181,8 @@ function renderKIndexForecast(data) {
|
||||
},
|
||||
options: {
|
||||
responsive: true,
|
||||
aspectRatio: 3,
|
||||
aspectRatio: isMobile ? 0.4 : 3,
|
||||
indexAxis: isMobile ? 'y' : 'x',
|
||||
plugins: {
|
||||
legend: {
|
||||
display: false
|
||||
@@ -172,22 +192,8 @@ function renderKIndexForecast(data) {
|
||||
}
|
||||
},
|
||||
scales: {
|
||||
x: {
|
||||
ticks: { color: textColor, maxRotation: 45, minRotation: 0 },
|
||||
grid: { color: gridColor },
|
||||
},
|
||||
y: {
|
||||
min: 0,
|
||||
max: 9,
|
||||
title: { display: true, text: 'Kp', color: textColor },
|
||||
// Include geomagnetic storm levels (Gx) on the y-axis as well as the Kp index
|
||||
ticks: {
|
||||
stepSize: 1,
|
||||
color: textColor,
|
||||
callback: v => v > 4 ? `(G${v - 4}) ${v}` : String(v),
|
||||
},
|
||||
grid: { color: gridColor },
|
||||
}
|
||||
x: isMobile ? kpAxis : timeAxis,
|
||||
y: isMobile ? timeAxis : kpAxis,
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user