mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Fixed display of outer points on linear chart.
This commit is contained in:
parent
aeee016dc9
commit
4624d34f68
2 changed files with 20 additions and 12 deletions
|
@ -1155,6 +1155,12 @@ void ChartWidget::setupDetails() {
|
||||||
currentXLimits,
|
currentXLimits,
|
||||||
chartRect,
|
chartRect,
|
||||||
state.point.x());
|
state.point.x());
|
||||||
|
if (nearestXIndex < 0) {
|
||||||
|
_details.widget->setXIndex(nearestXIndex);
|
||||||
|
_details.widget->hide();
|
||||||
|
_chartArea->update();
|
||||||
|
return;
|
||||||
|
}
|
||||||
const auto currentX = 0
|
const auto currentX = 0
|
||||||
+ chartRect.width() * InterpolationRatio(
|
+ chartRect.width() * InterpolationRatio(
|
||||||
currentXLimits.min,
|
currentXLimits.min,
|
||||||
|
|
|
@ -31,10 +31,11 @@ void PaintChartLine(
|
||||||
|
|
||||||
auto chartPoints = QPolygonF();
|
auto chartPoints = QPolygonF();
|
||||||
|
|
||||||
const auto localStart = std::max(0, int(c.xIndices.min));
|
constexpr auto kOffset = float64(2);
|
||||||
const auto localEnd = std::min(
|
const auto localStart = int(std::max(0., c.xIndices.min - kOffset));
|
||||||
int(c.chartData.xPercentage.size() - 1),
|
const auto localEnd = int(std::min(
|
||||||
int(c.xIndices.max));
|
float64(c.chartData.xPercentage.size() - 1),
|
||||||
|
c.xIndices.max + kOffset));
|
||||||
|
|
||||||
const auto ratio = Ratio(ratios, line.id);
|
const auto ratio = Ratio(ratios, line.id);
|
||||||
|
|
||||||
|
@ -185,10 +186,8 @@ int LinearChartView::findXIndexByPosition(
|
||||||
const Limits &xPercentageLimits,
|
const Limits &xPercentageLimits,
|
||||||
const QRect &rect,
|
const QRect &rect,
|
||||||
float64 x) {
|
float64 x) {
|
||||||
if (x < rect.x()) {
|
if ((x < rect.x()) || (x > (rect.x() + rect.width()))) {
|
||||||
return 0;
|
return -1;
|
||||||
} else if (x > (rect.x() + rect.width())) {
|
|
||||||
return chartData.xPercentage.size() - 1;
|
|
||||||
}
|
}
|
||||||
const auto pointerRatio = std::clamp(
|
const auto pointerRatio = std::clamp(
|
||||||
(x - rect.x()) / rect.width(),
|
(x - rect.x()) / rect.width(),
|
||||||
|
@ -203,10 +202,13 @@ int LinearChartView::findXIndexByPosition(
|
||||||
rawXPercentage);
|
rawXPercentage);
|
||||||
const auto left = rawXPercentage - (*(it - 1));
|
const auto left = rawXPercentage - (*(it - 1));
|
||||||
const auto right = (*it) - rawXPercentage;
|
const auto right = (*it) - rawXPercentage;
|
||||||
const auto nearestXPercentageIt = ((right) > (left)) ? (it - 1) : it;
|
const auto nearest = ((right) > (left)) ? (it - 1) : it;
|
||||||
return std::distance(
|
const auto resultXPercentageIt = ((*nearest) > xPercentageLimits.max)
|
||||||
begin(chartData.xPercentage),
|
? (nearest - 1)
|
||||||
nearestXPercentageIt);
|
: ((*nearest) < xPercentageLimits.min)
|
||||||
|
? (nearest + 1)
|
||||||
|
: nearest;
|
||||||
|
return std::distance(begin(chartData.xPercentage), resultXPercentageIt);
|
||||||
}
|
}
|
||||||
|
|
||||||
AbstractChartView::HeightLimits LinearChartView::heightLimits(
|
AbstractChartView::HeightLimits LinearChartView::heightLimits(
|
||||||
|
|
Loading…
Add table
Reference in a new issue