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) {
 | 
			
		||||
			Statistic::PaintLinearChartView(
 | 
			
		||||
				p,
 | 
			
		||||
| 
						 | 
				
			
			@ -653,16 +658,25 @@ void ChartWidget::setupChartArea() {
 | 
			
		|||
				_animationController.currentXLimits(),
 | 
			
		||||
				_animationController.currentHeightLimits(),
 | 
			
		||||
				chartRect,
 | 
			
		||||
				{
 | 
			
		||||
					_details.widget ? _details.widget->xIndex() : -1,
 | 
			
		||||
					detailsAlpha,
 | 
			
		||||
				});
 | 
			
		||||
				detailsPaintContext);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		for (auto &horizontalLine : _horizontalLines) {
 | 
			
		||||
			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(
 | 
			
		||||
			p,
 | 
			
		||||
			_bottomLine.dates,
 | 
			
		||||
| 
						 | 
				
			
			@ -750,6 +764,7 @@ void ChartWidget::setupFooter() {
 | 
			
		|||
		auto p = QPainter(_footer.get());
 | 
			
		||||
 | 
			
		||||
		if (_chartData) {
 | 
			
		||||
			auto detailsPaintContext = DetailsPaintContext{ .xIndex = -1 };
 | 
			
		||||
			p.fillRect(_footer->rect(), st::boxBg);
 | 
			
		||||
			Statistic::PaintLinearChartView(
 | 
			
		||||
				p,
 | 
			
		||||
| 
						 | 
				
			
			@ -757,7 +772,7 @@ void ChartWidget::setupFooter() {
 | 
			
		|||
				fullXLimits,
 | 
			
		||||
				_footer->fullHeightLimits(),
 | 
			
		||||
				_footer->rect(),
 | 
			
		||||
				{});
 | 
			
		||||
				detailsPaintContext);
 | 
			
		||||
		}
 | 
			
		||||
	}, _footer->lifetime());
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -22,7 +22,7 @@ void PaintLinearChartView(
 | 
			
		|||
		const Limits &xPercentageLimits,
 | 
			
		||||
		const Limits &heightLimits,
 | 
			
		||||
		const QRect &rect,
 | 
			
		||||
		const DetailsPaintContext &detailsPaintContext) {
 | 
			
		||||
		DetailsPaintContext &detailsPaintContext) {
 | 
			
		||||
	const auto currentMinHeight = rect.y(); //
 | 
			
		||||
	const auto currentMaxHeight = rect.height() + rect.y(); //
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -36,7 +36,6 @@ void PaintLinearChartView(
 | 
			
		|||
 | 
			
		||||
		auto first = true;
 | 
			
		||||
		auto chartPath = QPainterPath();
 | 
			
		||||
		auto detailsDotPoint = QPointF();
 | 
			
		||||
 | 
			
		||||
		const auto startXIndex = chartData.findStartIndex(
 | 
			
		||||
			xPercentageLimits.min);
 | 
			
		||||
| 
						 | 
				
			
			@ -59,9 +58,11 @@ void PaintLinearChartView(
 | 
			
		|||
			const auto yPercentage = (line.y[i] - heightLimits.min)
 | 
			
		||||
				/ float64(heightLimits.max - heightLimits.min);
 | 
			
		||||
			const auto yPoint = rect.y() + (1. - yPercentage) * rect.height();
 | 
			
		||||
			if ((i == detailsPaintContext.xIndex)
 | 
			
		||||
				&& detailsPaintContext.progress > 0.) {
 | 
			
		||||
				detailsDotPoint = QPointF(xPoint, yPoint);
 | 
			
		||||
			if (i == detailsPaintContext.xIndex) {
 | 
			
		||||
				detailsPaintContext.dots.push_back({
 | 
			
		||||
					QPointF(xPoint, yPoint),
 | 
			
		||||
					line.color,
 | 
			
		||||
				});
 | 
			
		||||
			}
 | 
			
		||||
			if (first) {
 | 
			
		||||
				first = false;
 | 
			
		||||
| 
						 | 
				
			
			@ -72,13 +73,6 @@ void PaintLinearChartView(
 | 
			
		|||
		p.setPen(QPen(line.color, st::statisticsChartLineWidth));
 | 
			
		||||
		p.setBrush(Qt::NoBrush);
 | 
			
		||||
		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);
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -22,6 +22,6 @@ void PaintLinearChartView(
 | 
			
		|||
	const Limits &xPercentageLimits,
 | 
			
		||||
	const Limits &heightLimits,
 | 
			
		||||
	const QRect &rect,
 | 
			
		||||
	const DetailsPaintContext &detailsPaintContext);
 | 
			
		||||
	DetailsPaintContext &detailsPaintContext);
 | 
			
		||||
 | 
			
		||||
} // namespace Statistic
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -17,7 +17,12 @@ struct Limits final {
 | 
			
		|||
// Dot on line charts.
 | 
			
		||||
struct DetailsPaintContext final {
 | 
			
		||||
	int xIndex = -1;
 | 
			
		||||
	float64 progress = 0.;
 | 
			
		||||
 | 
			
		||||
	struct Dot {
 | 
			
		||||
		QPointF point;
 | 
			
		||||
		QColor color;
 | 
			
		||||
	};
 | 
			
		||||
	std::vector<Dot> dots;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
} // namespace Statistic
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		
		Reference in a new issue