Fixed legend anchor bug

This commit is contained in:
l_samenv
2024-08-19 16:51:21 +02:00
parent 6ebcacdf12
commit 7bd4a1591f

View File

@ -1359,7 +1359,7 @@ function Graph(gindex, container, x_label, y_label, tag, scaleType = "linear"){
let legendAnchor = document.createElement('div');
legendAnchor.classList.add('legendanchor');
parent.appendChild(legendAnchor);
let hasLegendAnchor = false;
//graphSwiper.appendSlide(parent);
let controls = document.createElement('div');
controls.classList.add('controls');
@ -1463,6 +1463,7 @@ function Graph(gindex, container, x_label, y_label, tag, scaleType = "linear"){
let mid = y + lrect.height / 2;
if (mid >= 0 && mid <= prect.height) {
legendAnchor.style.display = 'none';
hasLegendAnchor = false;
return;
}
if (y < 0) {
@ -1473,6 +1474,7 @@ function Graph(gindex, container, x_label, y_label, tag, scaleType = "linear"){
legendAnchor.style.display = 'inline-block';
legendAnchor.style.left = x + lrect.width + 'px';
legendAnchor.style.top = y + 'px';
hasLegendAnchor = true;
}
/**
@ -1546,9 +1548,13 @@ function Graph(gindex, container, x_label, y_label, tag, scaleType = "linear"){
function showLegend(flag){
if (flag) {
legend.style.display = 'flex';
if (hasLegendAnchor)
legendAnchor.style.display = 'inline-block';
} else {
graphs.cursorLine(null);
legend.style.display = 'none';
if (hasLegendAnchor)
legendAnchor.style.display = 'none';
}
}