diff --git a/static/js/weather-chart.js b/static/js/weather-chart.js index 0bafcd8..0521079 100644 --- a/static/js/weather-chart.js +++ b/static/js/weather-chart.js @@ -87,8 +87,7 @@ const WeatherChart = { backgroundColor: 'rgba(255, 99, 132, 0.1)', yAxisID: 'y-temperature', tension: 0.4, - spanGaps: false, - legendGroup: 'history' + spanGaps: false }, { label: '湿度 (%) - 实测', @@ -98,8 +97,7 @@ const WeatherChart = { yAxisID: 'y-humidity', tension: 0.4, hidden: true, - spanGaps: false, - legendGroup: 'history' + spanGaps: false }, { label: '雨量 (mm) - 实测', @@ -107,8 +105,7 @@ const WeatherChart = { type: 'bar', backgroundColor: 'rgba(54, 162, 235, 0.6)', borderColor: 'rgb(54, 162, 235)', - yAxisID: 'y-rainfall', - legendGroup: 'history' + yAxisID: 'y-rainfall' }, { label: '累计雨量 (mm) - 实测', @@ -119,17 +116,16 @@ const WeatherChart = { tension: 0.2, spanGaps: false, pointRadius: 0, - hidden: true, - legendGroup: 'history' + hidden: true } ]; if (forecastData.length > 0) { // 雨量 仅显示 -1h/-2h/-3h datasets.push( - { label: '雨量 (mm) - 预报 (+1h)', data: forecastRainfallsH1, type: 'bar', backgroundColor: 'rgba(255, 99, 71, 0.55)', borderColor: 'rgb(255, 99, 71)', yAxisID: 'y-rainfall', legendGroup: 'forecast' }, - { label: '雨量 (mm) - 预报 (+2h)', data: forecastRainfallsH2, type: 'bar', backgroundColor: 'rgba(255, 205, 86, 0.55)', borderColor: 'rgb(255, 205, 86)', yAxisID: 'y-rainfall', legendGroup: 'forecast' }, - { label: '雨量 (mm) - 预报 (+3h)', data: forecastRainfallsH3, type: 'bar', backgroundColor: 'rgba(76, 175, 80, 0.55)', borderColor: 'rgb(76, 175, 80)', yAxisID: 'y-rainfall', legendGroup: 'forecast' } + { label: '雨量 (mm) - 预报 (+1h)', data: forecastRainfallsH1, type: 'bar', backgroundColor: 'rgba(255, 99, 71, 0.55)', borderColor: 'rgb(255, 99, 71)', yAxisID: 'y-rainfall' }, + { label: '雨量 (mm) - 预报 (+2h)', data: forecastRainfallsH2, type: 'bar', backgroundColor: 'rgba(255, 205, 86, 0.55)', borderColor: 'rgb(255, 205, 86)', yAxisID: 'y-rainfall' }, + { label: '雨量 (mm) - 预报 (+3h)', data: forecastRainfallsH3, type: 'bar', backgroundColor: 'rgba(76, 175, 80, 0.55)', borderColor: 'rgb(76, 175, 80)', yAxisID: 'y-rainfall' } ); // 温度 取最接近的预报(0h>1h>2h>3h) @@ -141,8 +137,7 @@ const WeatherChart = { borderDash: [5, 5], yAxisID: 'y-temperature', tension: 0.4, - spanGaps: false, - legendGroup: 'forecast' + spanGaps: false }); } @@ -158,20 +153,6 @@ const WeatherChart = { responsive: true, maintainAspectRatio: false, interaction: { mode: 'index', intersect: false }, - plugins: { - legend: { - position: 'top', - align: 'center', - labels: { - boxWidth: 30, - padding: 15, - font: { - size: 11 - } - }, - maxHeight: 80 - } - }, scales: { 'y-temperature': { type: 'linear', display: true, position: 'left', title: { display: true, text: '温度 (°C)' } }, 'y-humidity': { type: 'linear', display: true, position: 'right', title: { display: true, text: '湿度 (%)' }, grid: { drawOnChartArea: false }, min: 0, max: 100 },