mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-07 15:43:55 +02:00
Moved out details dots above horizontal line captions.
This commit is contained in:
parent
487dd27ca1
commit
f76f69b5cd
4 changed files with 33 additions and 19 deletions
|
@ -646,6 +646,11 @@ void ChartWidget::setupChartArea() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto detailsPaintContext = DetailsPaintContext{
|
||||||
|
.xIndex = (_details.widget && (detailsAlpha > 0.))
|
||||||
|
? _details.widget->xIndex()
|
||||||
|
: -1,
|
||||||
|
};
|
||||||
if (_chartData) {
|
if (_chartData) {
|
||||||
Statistic::PaintLinearChartView(
|
Statistic::PaintLinearChartView(
|
||||||
p,
|
p,
|
||||||
|
@ -653,16 +658,25 @@ void ChartWidget::setupChartArea() {
|
||||||
_animationController.currentXLimits(),
|
_animationController.currentXLimits(),
|
||||||
_animationController.currentHeightLimits(),
|
_animationController.currentHeightLimits(),
|
||||||
chartRect,
|
chartRect,
|
||||||
{
|
detailsPaintContext);
|
||||||
_details.widget ? _details.widget->xIndex() : -1,
|
|
||||||
detailsAlpha,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto &horizontalLine : _horizontalLines) {
|
for (auto &horizontalLine : _horizontalLines) {
|
||||||
PaintCaptionsToHorizontalLines(p, horizontalLine, chartRect);
|
PaintCaptionsToHorizontalLines(p, horizontalLine, chartRect);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
auto o = ScopedPainterOpacity(p, detailsAlpha);
|
||||||
|
for (const auto &dot : detailsPaintContext.dots) {
|
||||||
|
p.setBrush(st::boxBg);
|
||||||
|
p.setPen(QPen(dot.color, st::statisticsChartLineWidth));
|
||||||
|
const auto r = st::statisticsDetailsDotRadius;
|
||||||
|
auto hq = PainterHighQualityEnabler(p);
|
||||||
|
p.drawEllipse(dot.point, r, r);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
p.setPen(st::boxTextFg);
|
||||||
PaintBottomLine(
|
PaintBottomLine(
|
||||||
p,
|
p,
|
||||||
_bottomLine.dates,
|
_bottomLine.dates,
|
||||||
|
@ -750,6 +764,7 @@ void ChartWidget::setupFooter() {
|
||||||
auto p = QPainter(_footer.get());
|
auto p = QPainter(_footer.get());
|
||||||
|
|
||||||
if (_chartData) {
|
if (_chartData) {
|
||||||
|
auto detailsPaintContext = DetailsPaintContext{ .xIndex = -1 };
|
||||||
p.fillRect(_footer->rect(), st::boxBg);
|
p.fillRect(_footer->rect(), st::boxBg);
|
||||||
Statistic::PaintLinearChartView(
|
Statistic::PaintLinearChartView(
|
||||||
p,
|
p,
|
||||||
|
@ -757,7 +772,7 @@ void ChartWidget::setupFooter() {
|
||||||
fullXLimits,
|
fullXLimits,
|
||||||
_footer->fullHeightLimits(),
|
_footer->fullHeightLimits(),
|
||||||
_footer->rect(),
|
_footer->rect(),
|
||||||
{});
|
detailsPaintContext);
|
||||||
}
|
}
|
||||||
}, _footer->lifetime());
|
}, _footer->lifetime());
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@ void PaintLinearChartView(
|
||||||
const Limits &xPercentageLimits,
|
const Limits &xPercentageLimits,
|
||||||
const Limits &heightLimits,
|
const Limits &heightLimits,
|
||||||
const QRect &rect,
|
const QRect &rect,
|
||||||
const DetailsPaintContext &detailsPaintContext) {
|
DetailsPaintContext &detailsPaintContext) {
|
||||||
const auto currentMinHeight = rect.y(); //
|
const auto currentMinHeight = rect.y(); //
|
||||||
const auto currentMaxHeight = rect.height() + rect.y(); //
|
const auto currentMaxHeight = rect.height() + rect.y(); //
|
||||||
|
|
||||||
|
@ -36,7 +36,6 @@ void PaintLinearChartView(
|
||||||
|
|
||||||
auto first = true;
|
auto first = true;
|
||||||
auto chartPath = QPainterPath();
|
auto chartPath = QPainterPath();
|
||||||
auto detailsDotPoint = QPointF();
|
|
||||||
|
|
||||||
const auto startXIndex = chartData.findStartIndex(
|
const auto startXIndex = chartData.findStartIndex(
|
||||||
xPercentageLimits.min);
|
xPercentageLimits.min);
|
||||||
|
@ -59,9 +58,11 @@ void PaintLinearChartView(
|
||||||
const auto yPercentage = (line.y[i] - heightLimits.min)
|
const auto yPercentage = (line.y[i] - heightLimits.min)
|
||||||
/ float64(heightLimits.max - heightLimits.min);
|
/ float64(heightLimits.max - heightLimits.min);
|
||||||
const auto yPoint = rect.y() + (1. - yPercentage) * rect.height();
|
const auto yPoint = rect.y() + (1. - yPercentage) * rect.height();
|
||||||
if ((i == detailsPaintContext.xIndex)
|
if (i == detailsPaintContext.xIndex) {
|
||||||
&& detailsPaintContext.progress > 0.) {
|
detailsPaintContext.dots.push_back({
|
||||||
detailsDotPoint = QPointF(xPoint, yPoint);
|
QPointF(xPoint, yPoint),
|
||||||
|
line.color,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
if (first) {
|
if (first) {
|
||||||
first = false;
|
first = false;
|
||||||
|
@ -72,13 +73,6 @@ void PaintLinearChartView(
|
||||||
p.setPen(QPen(line.color, st::statisticsChartLineWidth));
|
p.setPen(QPen(line.color, st::statisticsChartLineWidth));
|
||||||
p.setBrush(Qt::NoBrush);
|
p.setBrush(Qt::NoBrush);
|
||||||
p.drawPath(chartPath);
|
p.drawPath(chartPath);
|
||||||
|
|
||||||
if (!detailsDotPoint.isNull()) {
|
|
||||||
ScopedPainterOpacity o(p, detailsPaintContext.progress);
|
|
||||||
p.setBrush(st::boxBg);
|
|
||||||
const auto r = st::statisticsDetailsDotRadius;
|
|
||||||
p.drawEllipse(detailsDotPoint, r, r);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
p.setPen(st::boxTextFg);
|
p.setPen(st::boxTextFg);
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,6 @@ void PaintLinearChartView(
|
||||||
const Limits &xPercentageLimits,
|
const Limits &xPercentageLimits,
|
||||||
const Limits &heightLimits,
|
const Limits &heightLimits,
|
||||||
const QRect &rect,
|
const QRect &rect,
|
||||||
const DetailsPaintContext &detailsPaintContext);
|
DetailsPaintContext &detailsPaintContext);
|
||||||
|
|
||||||
} // namespace Statistic
|
} // namespace Statistic
|
||||||
|
|
|
@ -17,7 +17,12 @@ struct Limits final {
|
||||||
// Dot on line charts.
|
// Dot on line charts.
|
||||||
struct DetailsPaintContext final {
|
struct DetailsPaintContext final {
|
||||||
int xIndex = -1;
|
int xIndex = -1;
|
||||||
float64 progress = 0.;
|
|
||||||
|
struct Dot {
|
||||||
|
QPointF point;
|
||||||
|
QColor color;
|
||||||
|
};
|
||||||
|
std::vector<Dot> dots;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Statistic
|
} // namespace Statistic
|
||||||
|
|
Loading…
Add table
Reference in a new issue