Hide performance graph labels when window is not wide enough

Affects issues:
- Fixed #1959
This commit is contained in:
Risto Lahtela 2021-07-03 10:34:16 +03:00
parent 806a1faf78
commit b968ab3c43

View File

@ -220,7 +220,7 @@ function mapToDataSeries(performanceData) {
}
function performanceChart(id, playersOnlineSeries, tpsSeries, cpuSeries, ramSeries, entitySeries, chunkSeries) {
graphs.push(Highcharts.stockChart(id, {
const chart = Highcharts.stockChart(id, {
rangeSelector: {
selected: 2,
buttons: linegraphButtons
@ -270,7 +270,23 @@ function performanceChart(id, playersOnlineSeries, tpsSeries, cpuSeries, ramSeri
enabled: true
},
series: [playersOnlineSeries, tpsSeries, cpuSeries, ramSeries, entitySeries, chunkSeries]
}));
});
function toggleLabels() {
if (!chart || !chart.yAxis || !chart.yAxis.length) return;
const newWidth = $(window).width();
chart.yAxis[0].update({labels: {enabled: newWidth >= 900}});
chart.yAxis[1].update({labels: {enabled: newWidth >= 900}});
chart.yAxis[2].update({labels: {enabled: newWidth >= 1000}});
chart.yAxis[3].update({labels: {enabled: newWidth >= 1000}});
chart.yAxis[4].update({labels: {enabled: newWidth >= 1400}});
chart.yAxis[5].update({labels: {enabled: newWidth >= 1400}});
}
$(window).resize(toggleLabels);
toggleLabels();
graphs.push(chart);
}
function playersChart(id, playersOnlineSeries, sel) {