Fixed position of zoomed in slider in footer for stack linear chart.
This commit is contained in:
		
							parent
							
								
									6995fcafb5
								
							
						
					
					
						commit
						c19a527872
					
				
					 3 changed files with 16 additions and 4 deletions
				
			
		| 
						 | 
					@ -479,8 +479,9 @@ void ChartWidget::Footer::paintEvent(QPaintEvent *e) {
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void ChartWidget::Footer::setXPercentageLimits(const Limits &xLimits) {
 | 
					void ChartWidget::Footer::setXPercentageLimits(const Limits &xLimits) {
 | 
				
			||||||
	const auto left = xLimits.min * width();
 | 
						const auto left = xLimits.min * _widthBetweenSides;
 | 
				
			||||||
	const auto right = xLimits.max * _width;
 | 
						const auto right = xLimits.max * _widthBetweenSides
 | 
				
			||||||
 | 
							+ st::statisticsChartFooterSideWidth;
 | 
				
			||||||
	moveSide(true, left);
 | 
						moveSide(true, left);
 | 
				
			||||||
	moveSide(false, right);
 | 
						moveSide(false, right);
 | 
				
			||||||
	fire();
 | 
						fire();
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -39,6 +39,10 @@ Limits FindStackXIndicesFromRawXPercentages(
 | 
				
			||||||
		chartData.xPercentage[zoomedInLimitXIndices.min],
 | 
							chartData.xPercentage[zoomedInLimitXIndices.min],
 | 
				
			||||||
		chartData.xPercentage[zoomedInLimitXIndices.max],
 | 
							chartData.xPercentage[zoomedInLimitXIndices.max],
 | 
				
			||||||
	};
 | 
						};
 | 
				
			||||||
 | 
						// Due to a specificity of the stack chart plotting,
 | 
				
			||||||
 | 
						// the right edge has a special offset to the left.
 | 
				
			||||||
 | 
						// This reduces the number of displayed points by 1,
 | 
				
			||||||
 | 
						// but allows the last point to be displayed.
 | 
				
			||||||
	const auto offset = (zoomLimit.max == 1.) ? 0 : -1;
 | 
						const auto offset = (zoomLimit.max == 1.) ? 0 : -1;
 | 
				
			||||||
	const auto minIt = ranges::upper_bound(
 | 
						const auto minIt = ranges::upper_bound(
 | 
				
			||||||
		chartData.xPercentage,
 | 
							chartData.xPercentage,
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -585,6 +585,7 @@ void StackLinearChartView::paintZoomedFooter(
 | 
				
			||||||
	const auto leftStart = c.rect.x() + sideW;
 | 
						const auto leftStart = c.rect.x() + sideW;
 | 
				
			||||||
	const auto &xPercentage = c.chartData.xPercentage;
 | 
						const auto &xPercentage = c.chartData.xPercentage;
 | 
				
			||||||
	auto previousX = leftStart;
 | 
						auto previousX = leftStart;
 | 
				
			||||||
 | 
						// Read FindStackXIndicesFromRawXPercentages.
 | 
				
			||||||
	const auto offset = (xPercentage[zoomedEnd] == 1.) ? 0 : 1;
 | 
						const auto offset = (xPercentage[zoomedEnd] == 1.) ? 0 : 1;
 | 
				
			||||||
	for (auto i = zoomedStart; i <= zoomedEnd; i++) {
 | 
						for (auto i = zoomedStart; i <= zoomedEnd; i++) {
 | 
				
			||||||
		auto sum = 0.;
 | 
							auto sum = 0.;
 | 
				
			||||||
| 
						 | 
					@ -958,15 +959,21 @@ auto StackLinearChartView::maybeLocalZoom(
 | 
				
			||||||
			xPercentage[_transition.zoomedInLimitXIndices.max],
 | 
								xPercentage[_transition.zoomedInLimitXIndices.max],
 | 
				
			||||||
			args.progress),
 | 
								args.progress),
 | 
				
			||||||
	};
 | 
						};
 | 
				
			||||||
 | 
						const auto oneDay = std::abs(xPercentage[localRangeIndex]
 | 
				
			||||||
 | 
							- xPercentage[localRangeIndex + ((xIndex == backIndex) ? -1 : 1)]);
 | 
				
			||||||
 | 
						// Read FindStackXIndicesFromRawXPercentages.
 | 
				
			||||||
 | 
						const auto offset = (_transition.zoomedInLimitXIndices.max == backIndex)
 | 
				
			||||||
 | 
							? -oneDay
 | 
				
			||||||
 | 
							: 0.;
 | 
				
			||||||
	const auto resultRange = Limits{
 | 
						const auto resultRange = Limits{
 | 
				
			||||||
		InterpolationRatio(
 | 
							InterpolationRatio(
 | 
				
			||||||
			_transition.zoomedInLimit.min,
 | 
								_transition.zoomedInLimit.min,
 | 
				
			||||||
			_transition.zoomedInLimit.max,
 | 
								_transition.zoomedInLimit.max,
 | 
				
			||||||
			_transition.zoomedInRange.min),
 | 
								_transition.zoomedInRange.min + oneDay * 0.25 + offset),
 | 
				
			||||||
		InterpolationRatio(
 | 
							InterpolationRatio(
 | 
				
			||||||
			_transition.zoomedInLimit.min,
 | 
								_transition.zoomedInLimit.min,
 | 
				
			||||||
			_transition.zoomedInLimit.max,
 | 
								_transition.zoomedInLimit.max,
 | 
				
			||||||
			_transition.zoomedInRange.max),
 | 
								_transition.zoomedInRange.max + oneDay * 0.75 + offset),
 | 
				
			||||||
	};
 | 
						};
 | 
				
			||||||
	return { true, _transition.zoomedInLimitXIndices, resultRange };
 | 
						return { true, _transition.zoomedInLimitXIndices, resultRange };
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		
		Reference in a new issue