mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-10-08 19:10:53 +00:00
Fix chart size and clipping
This commit is contained in:
parent
4f98fae2ef
commit
13cd7a2ab6
@ -17,7 +17,7 @@ prepare_build_variables () {
|
||||
;;
|
||||
esac
|
||||
|
||||
local BAZEL="$(which bazel)"
|
||||
local BAZEL="/Users/ilya/bin/bazel"
|
||||
if [ "$BAZEL" = "" ]; then
|
||||
echo "bazel not found in PATH"
|
||||
exit 1
|
||||
|
@ -16,7 +16,7 @@ import UIKit
|
||||
|
||||
enum BaseConstants {
|
||||
static let defaultRange: ClosedRange<CGFloat> = 0...1
|
||||
static let minimumAxisYLabelsDistance: CGFloat = 90
|
||||
static let minimumAxisYLabelsDistance: CGFloat = 85
|
||||
static let monthDayDateFormatter = DateFormatter.utc(format: "MMM d")
|
||||
static let timeDateFormatter = DateFormatter.utc(format: "HH:mm")
|
||||
static let headerFullRangeFormatter: DateFormatter = {
|
||||
|
@ -156,7 +156,6 @@ public class TwoAxisStepBarsChartController: BaseLinesChartController {
|
||||
super.chartInteractionDidBegin(point: point)
|
||||
|
||||
for graphController in graphControllers {
|
||||
|
||||
var bullets: [LineBulletsRenderer.Bullet] = []
|
||||
if let component = graphController.chartBars.components.first {
|
||||
let location = graphController.chartBars.locations[minIndex]
|
||||
|
@ -197,9 +197,7 @@ class BarChartRenderer: BaseChartRenderer {
|
||||
leftX = rightX
|
||||
barIndex += 1
|
||||
}
|
||||
|
||||
let colorOffset = Double((1.0 - (1.0 - generalUnselectedAlpha) * selectedIndexAnimator.current) * chartsAlpha)
|
||||
|
||||
|
||||
for (index, component) in bars.components.enumerated().reversed() {
|
||||
if maxValues[index] < optimizationLevel {
|
||||
continue
|
||||
@ -209,7 +207,7 @@ class BarChartRenderer: BaseChartRenderer {
|
||||
context.setLineWidth(self.lineWidth)
|
||||
context.setStrokeColor(GColor.valueBetween(start: backgroundColorAnimator.current.color,
|
||||
end: component.color,
|
||||
offset: colorOffset).cgColor)
|
||||
offset: 1.0).cgColor)
|
||||
context.beginPath()
|
||||
context.addLines(between: backgroundPaths[index])
|
||||
context.strokePath()
|
||||
|
@ -59,6 +59,8 @@ class LinesChartRenderer: BaseChartRenderer {
|
||||
if chartsAlpha == 0 { return }
|
||||
let range = renderRange(bounds: bounds, chartFrame: chartFrame)
|
||||
|
||||
context.clip(to: CGRect(origin: CGPoint(x: 0.0, y: chartFrame.minY), size: CGSize(width: chartFrame.width + chartFrame.origin.x * 2.0, height: chartFrame.height)))
|
||||
|
||||
for (index, toLine) in toLines.enumerated() {
|
||||
let alpha = linesAlphaAnimators[index].current * chartsAlpha
|
||||
if alpha == 0 { continue }
|
||||
@ -434,6 +436,8 @@ class LinesChartRenderer: BaseChartRenderer {
|
||||
}
|
||||
context.setAlpha(1.0)
|
||||
}
|
||||
|
||||
context.resetClip()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -32,7 +32,7 @@ class VerticalScalesRenderer: BaseChartRenderer {
|
||||
}
|
||||
}
|
||||
var horizontalLinesWidth: CGFloat = GView.oneDevicePixel
|
||||
var lavelsAsisOffset: CGFloat = 6
|
||||
var labelsAxisOffset: CGFloat = 6
|
||||
var labelsColor: GColor = .black {
|
||||
didSet {
|
||||
setNeedsDisplay()
|
||||
@ -118,18 +118,14 @@ class VerticalScalesRenderer: BaseChartRenderer {
|
||||
func drawVerticalLabels(_ labels: [LinesChartLabel], attributes: [NSAttributedString.Key: Any]) {
|
||||
if isRightAligned {
|
||||
for label in labels {
|
||||
let y = transform(toChartCoordinateVertical: label.value, chartFrame: chartFrame) - labelsFont.pointSize - lavelsAsisOffset
|
||||
|
||||
|
||||
|
||||
|
||||
let y = transform(toChartCoordinateVertical: label.value, chartFrame: chartFrame) - labelsFont.pointSize - labelsAxisOffset
|
||||
let attributedString = NSAttributedString(string: label.text, attributes: attributes)
|
||||
let textNode = LabelNode.layoutText(attributedString, bounds.size)
|
||||
textNode.1.draw(CGRect(origin: CGPoint(x:chartFrame.maxX - textNode.0.size.width, y: y), size: textNode.0.size), in: context, backingScaleFactor: deviceScale)
|
||||
}
|
||||
} else {
|
||||
for label in labels {
|
||||
let y = transform(toChartCoordinateVertical: label.value, chartFrame: chartFrame) - labelsFont.pointSize - lavelsAsisOffset
|
||||
let y = transform(toChartCoordinateVertical: label.value, chartFrame: chartFrame) - labelsFont.pointSize - labelsAxisOffset
|
||||
let attributedString = NSAttributedString(string: label.text, attributes: attributes)
|
||||
let textNode = LabelNode.layoutText(attributedString, bounds.size)
|
||||
textNode.1.draw(CGRect(origin: CGPoint(x:chartFrame.minX, y: y), size: textNode.0.size), in: context, backingScaleFactor: deviceScale)
|
||||
|
@ -152,12 +152,12 @@ class ChartStackSection: UIView, ChartThemeContainer {
|
||||
let bounds = self.bounds
|
||||
self.titleLabel.frame = CGRect(origin: CGPoint(x: backButton.alpha > 0.0 ? 36.0 : 0.0, y: 5.0), size: CGSize(width: bounds.width, height: 28.0))
|
||||
self.sectionContainerView.frame = CGRect(origin: CGPoint(), size: CGSize(width: bounds.width, height: 750.0))
|
||||
self.chartView.frame = CGRect(origin: CGPoint(), size: CGSize(width: bounds.width, height: 250.0))
|
||||
self.chartView.frame = CGRect(origin: CGPoint(), size: CGSize(width: bounds.width, height: 310.0))
|
||||
|
||||
self.rangeView.isHidden = !self.displayRange
|
||||
|
||||
self.rangeView.frame = CGRect(origin: CGPoint(x: 0.0, y: 250.0), size: CGSize(width: bounds.width, height: 42.0))
|
||||
self.visibilityView.frame = CGRect(origin: CGPoint(x: 0.0, y: self.displayRange ? 308.0 : 266.0), size: CGSize(width: bounds.width, height: 350.0))
|
||||
self.rangeView.frame = CGRect(origin: CGPoint(x: 0.0, y: 310.0), size: CGSize(width: bounds.width, height: 42.0))
|
||||
self.visibilityView.frame = CGRect(origin: CGPoint(x: 0.0, y: self.displayRange ? 368.0 : 326.0), size: CGSize(width: bounds.width, height: 350.0))
|
||||
self.backButton.frame = CGRect(x: 0.0, y: 0.0, width: 96.0, height: 38.0)
|
||||
|
||||
self.chartView.setNeedsDisplay()
|
||||
|
Loading…
x
Reference in New Issue
Block a user