Added ability to hide point details on chart by second click.

This commit is contained in:
23rd 2023-09-08 13:08:03 +03:00 committed by John Preston
parent b606a7b21d
commit ecce9dbaaa
1 changed files with 6 additions and 1 deletions

View File

@ -1192,6 +1192,7 @@ void ChartWidget::setupDetails() {
switch (state.mouseState) {
case QEvent::MouseButtonPress:
case QEvent::MouseMove: {
const auto wasXIndex = _details.widget->xIndex();
const auto chartRect = chartAreaRect();
const auto currentXLimits = _animationController.finalXLimits();
const auto nearestXIndex = _chartView->findXIndexByPosition(
@ -1218,6 +1219,10 @@ void ChartWidget::setupDetails() {
if (_details.widget->isHidden()) {
_details.hideOnAnimationEnd = false;
_details.animation.start();
} else if ((state.mouseState == QEvent::MouseButtonPress)
&& (wasXIndex == nearestXIndex)) {
_details.hideOnAnimationEnd = true;
_details.animation.start();
}
_details.widget->show();
_chartArea->update();
@ -1233,7 +1238,6 @@ void ChartWidget::setupDetails() {
0.,
1.);
const auto alpha = _details.hideOnAnimationEnd ? (1. - value) : value;
_chartArea->update();
if (_details.widget) {
_details.widget->setAlpha(alpha);
_details.widget->update();
@ -1245,6 +1249,7 @@ void ChartWidget::setupDetails() {
}
_details.animation.stop();
}
_chartArea->update();
});
}