Fixed legend anchor bug
This commit is contained in:
@ -1359,7 +1359,7 @@ function Graph(gindex, container, x_label, y_label, tag, scaleType = "linear"){
|
|||||||
let legendAnchor = document.createElement('div');
|
let legendAnchor = document.createElement('div');
|
||||||
legendAnchor.classList.add('legendanchor');
|
legendAnchor.classList.add('legendanchor');
|
||||||
parent.appendChild(legendAnchor);
|
parent.appendChild(legendAnchor);
|
||||||
|
let hasLegendAnchor = false;
|
||||||
//graphSwiper.appendSlide(parent);
|
//graphSwiper.appendSlide(parent);
|
||||||
let controls = document.createElement('div');
|
let controls = document.createElement('div');
|
||||||
controls.classList.add('controls');
|
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;
|
let mid = y + lrect.height / 2;
|
||||||
if (mid >= 0 && mid <= prect.height) {
|
if (mid >= 0 && mid <= prect.height) {
|
||||||
legendAnchor.style.display = 'none';
|
legendAnchor.style.display = 'none';
|
||||||
|
hasLegendAnchor = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (y < 0) {
|
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.display = 'inline-block';
|
||||||
legendAnchor.style.left = x + lrect.width + 'px';
|
legendAnchor.style.left = x + lrect.width + 'px';
|
||||||
legendAnchor.style.top = y + '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){
|
function showLegend(flag){
|
||||||
if (flag) {
|
if (flag) {
|
||||||
legend.style.display = 'flex';
|
legend.style.display = 'flex';
|
||||||
|
if (hasLegendAnchor)
|
||||||
|
legendAnchor.style.display = 'inline-block';
|
||||||
} else {
|
} else {
|
||||||
graphs.cursorLine(null);
|
graphs.cursorLine(null);
|
||||||
legend.style.display = 'none';
|
legend.style.display = 'none';
|
||||||
|
if (hasLegendAnchor)
|
||||||
|
legendAnchor.style.display = 'none';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user