Skip to content

Commit

Permalink
Merge branch 'ChartsOrg:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
joeboyscout04 authored Apr 10, 2024
2 parents 1a152f8 + 29e4f58 commit 804008c
Show file tree
Hide file tree
Showing 37 changed files with 179 additions and 71 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/swift.yml → .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Swift
name: Build

on:
workflow_dispatch:
Expand Down Expand Up @@ -77,5 +77,5 @@ jobs:
DEVELOPER_DIR: /Applications/Xcode_14.2.app/Contents/Developer
steps:
- uses: actions/checkout@v3
- name: Carthage Test
- name: Cocoapdos Test
run: pod lib lint
25 changes: 25 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Release

on:
workflow_dispatch:
push:
tags:
- "*"

jobs:
build:
runs-on: macos-12

steps:
- uses: actions/checkout@v1

- name: Install Cocoapods
run: gem install cocoapods

- name: Deploy to Cocoapods
run: |
set -eo pipefail
pod lib lint --allow-warnings
pod trunk push --allow-warnings
env:
COCOAPODS_TRUNK_TOKEN: ${{ secrets.COCOAPODS_TRUNK_TOKEN }}
10 changes: 7 additions & 3 deletions Charts.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
archiveVersion = 1;
classes = {
};
objectVersion = 53;
objectVersion = 54;
objects = {

/* Begin PBXBuildFile section */
Expand Down Expand Up @@ -51,6 +51,7 @@
3395682A1E27756651FF6F4D /* BarChartData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0108D5925E21A47DA36A66AA /* BarChartData.swift */; };
369DEB23452CB436A3A1A644 /* MarkerImage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 392AAEB02DD7B351D92907C2 /* MarkerImage.swift */; };
383D68A13E1C3D6A251E5147 /* CandleChartDataSet.swift in Sources */ = {isa = PBXBuildFile; fileRef = 274116834B1B0345D622E027 /* CandleChartDataSet.swift */; };
39279C482B6B643600204A3D /* PrivacyInfo.xcprivacy in Resources */ = {isa = PBXBuildFile; fileRef = 3959DF712B4BD33000A20423 /* PrivacyInfo.xcprivacy */; };
3B11556EB7DC034E2FC958E4 /* BarChartTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5C3F5E1A69EC06E86505F7B1 /* BarChartTests.swift */; };
3CBE95F1E9394FA08CDCF31E /* BarHighlighter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 543729805D897CC03E5F78D3 /* BarHighlighter.swift */; };
40C82F2209E1BA9E41E8F3DA /* ChartColorTemplates.swift in Sources */ = {isa = PBXBuildFile; fileRef = F6227A646166E248F90F86AD /* ChartColorTemplates.swift */; };
Expand Down Expand Up @@ -217,6 +218,7 @@
32FC01A016DFF1BA73AF9182 /* SquareShapeRenderer.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = SquareShapeRenderer.swift; path = Source/Charts/Renderers/Scatter/SquareShapeRenderer.swift; sourceTree = "<group>"; };
33BE9A97FFA41D3D85CAFFC7 /* HorizontalBarHighlighter.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = HorizontalBarHighlighter.swift; path = Source/Charts/Highlight/HorizontalBarHighlighter.swift; sourceTree = "<group>"; };
392AAEB02DD7B351D92907C2 /* MarkerImage.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = MarkerImage.swift; path = Source/Charts/Components/MarkerImage.swift; sourceTree = "<group>"; };
3959DF712B4BD33000A20423 /* PrivacyInfo.xcprivacy */ = {isa = PBXFileReference; lastKnownFileType = text.xml; name = PrivacyInfo.xcprivacy; path = Source/Charts/PrivacyInfo.xcprivacy; sourceTree = "<group>"; };
3976E5F9D60E30CD94CE6156 /* Animator.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = Animator.swift; path = Source/Charts/Animation/Animator.swift; sourceTree = "<group>"; };
3A32510073A303CBB38E094A /* ChartDataSetProtocol.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = ChartDataSetProtocol.swift; path = Source/Charts/Data/Interfaces/ChartDataSetProtocol.swift; sourceTree = "<group>"; };
3D64616883374310C505EC39 /* Highlight.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = Highlight.swift; path = Source/Charts/Highlight/Highlight.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -486,6 +488,7 @@
AD1224C45A29A5C88D6B7450 /* Jobs */,
E7589D3E7C2BD2449960AD59 /* Renderers */,
D047819AB7170595896D6FE8 /* Utils */,
3959DF712B4BD33000A20423 /* PrivacyInfo.xcprivacy */,
);
name = Charts;
sourceTree = "<group>";
Expand Down Expand Up @@ -837,6 +840,7 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
39279C482B6B643600204A3D /* PrivacyInfo.xcprivacy in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -1047,7 +1051,7 @@
"@loader_path/Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = "$(RECOMMENDED_MACOSX_DEPLOYMENT_TARGET)";
MARKETING_VERSION = 5.0.0;
MARKETING_VERSION = 5.1.0;
MODULE_VERIFIER_SUPPORTED_LANGUAGES = "objective-c objective-c++";
MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu99 gnu++11";
MTL_ENABLE_DEBUG_INFO = YES;
Expand Down Expand Up @@ -1240,7 +1244,7 @@
"@loader_path/Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = "$(RECOMMENDED_MACOSX_DEPLOYMENT_TARGET)";
MARKETING_VERSION = 5.0.0;
MARKETING_VERSION = 5.1.0;
MODULE_VERIFIER_SUPPORTED_LANGUAGES = "objective-c objective-c++";
MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu99 gnu++11";
MTL_ENABLE_DEBUG_INFO = NO;
Expand Down
6 changes: 4 additions & 2 deletions DGCharts.podspec
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
Pod::Spec.new do |s|
s.name = "DGCharts"
s.version = "5.0.0"
s.version = "5.1.0"
s.summary = "DGCharts is a powerful & easy to use chart library for iOS, tvOS and OSX (and Android)"
s.homepage = "https://github.com/danielgindi/Charts"
s.license = { :type => "Apache License, Version 2.0", :file => "LICENSE" }
s.authors = "Daniel Cohen Gindi", "Philipp Jahoda"
s.ios.deployment_target = "12.0"
s.tvos.deployment_target = "12.0"
s.osx.deployment_target = "10.13"
s.source = { :git => "https://github.com/danielgindi/Charts.git", :tag => "v#{s.version}" }
s.source = { :git => "https://github.com/danielgindi/Charts.git", :tag => "#{s.version}" }
s.default_subspec = "Core"
s.swift_version = '5.7'
s.cocoapods_version = '>= 1.5.0'

s.resource_bundles = {"DGCharts" => ["Source/Charts/PrivacyInfo.xcprivacy"]}

s.subspec "Core" do |ss|
ss.source_files = "Source/Charts/**/*.swift"
end
Expand Down
5 changes: 3 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version:5.1
// swift-tools-version:5.3
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription

Expand All @@ -21,7 +21,8 @@ let package = Package(
targets: [
.target(
name: "DGCharts",
path: "Source/Charts"
path: "Source/Charts",
resources: [.copy("PrivacyInfo.xcprivacy")]
)
],
swiftLanguageVersions: [.v5]
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
![Supported Platforms](https://img.shields.io/cocoapods/p/Charts.svg) [![Releases](https://img.shields.io/github/release/danielgindi/Charts.svg)](https://github.com/danielgindi/Charts/releases) [![Latest pod release](https://img.shields.io/cocoapods/v/Charts.svg)](http://cocoapods.org/pods/charts) [![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage) [![Build Status](https://travis-ci.org/danielgindi/Charts.svg?branch=master)](https://travis-ci.org/danielgindi/Charts) [![codecov](https://codecov.io/gh/danielgindi/Charts/branch/master/graph/badge.svg)](https://codecov.io/gh/danielgindi/Charts)
[![Join the chat at https://gitter.im/danielgindi/Charts](https://badges.gitter.im/danielgindi/Charts.svg)](https://gitter.im/danielgindi/Charts?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)

### Just a heads up: Charts 5.0 has some breaking changes. Charts has now been renamed DGCharts to prevent conflicts with Apple's new Swift Charts. Please read [the release/migration notes](https://github.com/danielgindi/Charts/releases/tag/v5.0.0).
### Just a heads up: Charts 5.0 has some breaking changes. Charts has now been renamed DGCharts to prevent conflicts with Apple's new Swift Charts. Please read [the release/migration notes](https://github.com/danielgindi/Charts/releases/tag/5.0.0).

### One more heads up: As Swift evolves, if you are not using the latest Swift compiler, you shouldn't check out the master branch. Instead, you should go to the release page and pick up whatever suits you.

Expand Down Expand Up @@ -93,8 +93,8 @@ For [Realm](https://realm.io/) support, please add `pod 'ChartsRealm'` too.
DGCharts now include Carthage prebuilt binaries.

```carthage
github "danielgindi/DGCharts" == 5.0.0
github "danielgindi/DGCharts" ~> 5.0.0
github "danielgindi/Charts" == 5.1.0
github "danielgindi/Charts" ~> 5.1.0
```

In order to build the binaries for a new release, use `carthage build --no-skip-current && carthage archive Charts`.
Expand All @@ -105,7 +105,7 @@ Swift Package Manager

```swift
dependencies: [
.package(url: "https://github.com/danielgindi/Charts.git", .upToNextMajor(from: "5.0.0"))
.package(url: "https://github.com/danielgindi/Charts.git", .upToNextMajor(from: "5.1.0"))
]
```

Expand Down
1 change: 1 addition & 0 deletions Source/Charts/Components/ChartLimitLine.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ open class ChartLimitLine: ComponentBase
@objc open var drawLabelEnabled = true
@objc open var label = ""
@objc open var labelPosition = LabelPosition.rightTop
@objc open var labelRotationAngle = CGFloat(0.0)

public override init()
{
Expand Down
14 changes: 14 additions & 0 deletions Source/Charts/PrivacyInfo.xcprivacy
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>NSPrivacyTracking</key>
<false/>
<key>NSPrivacyCollectedDataTypes</key>
<array/>
<key>NSPrivacyTrackingDomains</key>
<array/>
<key>NSPrivacyAccessedAPITypes</key>
<array/>
</dict>
</plist>
39 changes: 22 additions & 17 deletions Source/Charts/Renderers/XAxisRenderer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -449,40 +449,45 @@ open class XAxisRenderer: NSObject, AxisRenderer
// if drawing the limit-value label is enabled
guard limitLine.drawLabelEnabled, !label.isEmpty else { return }

let labelLineHeight = limitLine.valueFont.lineHeight
let labelLineSize = label.size(withAttributes: [.font: limitLine.valueFont])
let labelLineRotatedSize = labelLineSize.rotatedBy(degrees: limitLine.labelRotationAngle)
let labelLineRotatedWidth = labelLineRotatedSize.width
let labelLineRotatedHeight = labelLineRotatedSize.height

let xOffset: CGFloat = limitLine.lineWidth + limitLine.xOffset
let labelRotationAngleRadians = limitLine.labelRotationAngle.DEG2RAD

let align: TextAlignment
let point: CGPoint
let anchor = CGPoint(x: 0.0, y: 0.0)

switch limitLine.labelPosition
{
switch limitLine.labelPosition {
case .rightTop:
align = .left
point = CGPoint(x: position.x + xOffset,
y: viewPortHandler.contentTop + yOffset)
point = CGPoint(
x: position.x + xOffset,
y: viewPortHandler.contentTop + yOffset)

case .rightBottom:
align = .left
point = CGPoint(x: position.x + xOffset,
y: viewPortHandler.contentBottom - labelLineHeight - yOffset)
y: viewPortHandler.contentBottom - labelLineRotatedHeight - yOffset)

case .leftTop:
align = .right
point = CGPoint(x: position.x - xOffset,
point = CGPoint(x: position.x - labelLineRotatedWidth - xOffset,
y: viewPortHandler.contentTop + yOffset)

case .leftBottom:
align = .right
point = CGPoint(x: position.x - xOffset,
y: viewPortHandler.contentBottom - labelLineHeight - yOffset)
point = CGPoint(x: position.x - labelLineRotatedWidth - xOffset,
y: viewPortHandler.contentBottom - labelLineRotatedHeight - yOffset)
}

let attributes: [NSAttributedString.Key : Any] = [
.font: limitLine.valueFont,
.foregroundColor: limitLine.valueTextColor
]

context.drawText(label,
at: point,
align: align,
attributes: [.font: limitLine.valueFont,
.foregroundColor: limitLine.valueTextColor])
anchor: anchor,
angleRadians: labelRotationAngleRadians,
attributes: attributes)
}
}
35 changes: 21 additions & 14 deletions Source/Charts/Renderers/XAxisRendererHorizontalBarChart.swift
Original file line number Diff line number Diff line change
Expand Up @@ -249,41 +249,48 @@ open class XAxisRendererHorizontalBarChart: XAxisRenderer
// if drawing the limit-value label is enabled
if l.drawLabelEnabled, !label.isEmpty
{
let labelLineHeight = l.valueFont.lineHeight


let labelLineSize = label.size(withAttributes: [.font: l.valueFont])
let labelLineRotatedSize = labelLineSize.rotatedBy(degrees: l.labelRotationAngle)
let labelLineRotatedWidth = labelLineRotatedSize.width
let labelLineRotatedHeight = labelLineRotatedSize.height

let xOffset = 4.0 + l.xOffset
let yOffset = l.lineWidth + labelLineHeight + l.yOffset
let yOffset = l.lineWidth + labelLineRotatedHeight + l.yOffset
let labelRotationAngleRadians = l.labelRotationAngle.DEG2RAD

let align: TextAlignment
let point: CGPoint
let anchor = CGPoint(x: 0.0, y: 0.0)

switch l.labelPosition
{
case .rightTop:
align = .right
point = CGPoint(x: viewPortHandler.contentRight - xOffset,
point = CGPoint(x: viewPortHandler.contentRight - labelLineRotatedWidth - xOffset,
y: position.y - yOffset)

case .rightBottom:
align = .right
point = CGPoint(x: viewPortHandler.contentRight - xOffset,
y: position.y + yOffset - labelLineHeight)
point = CGPoint(x: viewPortHandler.contentRight - labelLineRotatedWidth - xOffset,
y: position.y - labelLineRotatedHeight + yOffset)

case .leftTop:
align = .left
point = CGPoint(x: viewPortHandler.contentLeft + xOffset,
y: position.y - yOffset)

case .leftBottom:
align = .left
point = CGPoint(x: viewPortHandler.contentLeft + xOffset,
y: position.y + yOffset - labelLineHeight)
y: position.y - labelLineRotatedHeight + yOffset)
}

let attributes: [NSAttributedString.Key : Any] = [
.font: l.valueFont,
.foregroundColor: l.valueTextColor
]

context.drawText(label,
at: point,
align: align,
attributes: [.font: l.valueFont, .foregroundColor: l.valueTextColor])
anchor: anchor,
angleRadians: labelRotationAngleRadians,
attributes: attributes)
}
}
}
Expand Down
34 changes: 20 additions & 14 deletions Source/Charts/Renderers/YAxisRenderer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -295,41 +295,47 @@ open class YAxisRenderer: NSObject, AxisRenderer
// if drawing the limit-value label is enabled
guard l.drawLabelEnabled, !label.isEmpty else { continue }

let labelLineHeight = l.valueFont.lineHeight

let labelLineSize = label.size(withAttributes: [.font: l.valueFont])
let labelLineRotatedSize = labelLineSize.rotatedBy(degrees: l.labelRotationAngle)
let labelLineRotatedWidth = labelLineRotatedSize.width
let labelLineRotatedHeight = labelLineRotatedSize.height

let xOffset = 4.0 + l.xOffset
let yOffset = l.lineWidth + labelLineHeight + l.yOffset
let yOffset = l.lineWidth + labelLineRotatedHeight + l.yOffset
let labelRotationAngleRadians = l.labelRotationAngle.DEG2RAD

let align: TextAlignment
let point: CGPoint
let anchor = CGPoint(x: 0.0, y: 0.0)

switch l.labelPosition
{
case .rightTop:
align = .right
point = CGPoint(x: viewPortHandler.contentRight - xOffset,
point = CGPoint(x: viewPortHandler.contentRight - labelLineRotatedWidth - xOffset,
y: position.y - yOffset)

case .rightBottom:
align = .right
point = CGPoint(x: viewPortHandler.contentRight - xOffset,
y: position.y + yOffset - labelLineHeight)
point = CGPoint(x: viewPortHandler.contentRight - labelLineRotatedWidth - xOffset,
y: position.y - labelLineRotatedHeight + yOffset)

case .leftTop:
align = .left
point = CGPoint(x: viewPortHandler.contentLeft + xOffset,
y: position.y - yOffset)

case .leftBottom:
align = .left
point = CGPoint(x: viewPortHandler.contentLeft + xOffset,
y: position.y + yOffset - labelLineHeight)
y: position.y - labelLineRotatedHeight + yOffset)
}

let attributes: [NSAttributedString.Key : Any] = [
.font: l.valueFont,
.foregroundColor: l.valueTextColor
]

context.drawText(label,
at: point,
align: align,
attributes: [.font: l.valueFont, .foregroundColor: l.valueTextColor])
anchor: anchor,
angleRadians: labelRotationAngleRadians,
attributes: attributes)
}
}

Expand Down
Loading

0 comments on commit 804008c

Please sign in to comment.