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