Skip to content

Commit

Permalink
SPM GitHub Action (ChartsOrg#4553)
Browse files Browse the repository at this point in the history
* Create swift.yml

* Update project so SPM builds for all platforms

* Fix AutoreleaseingUnsafePointer warning

* Remove tests from github SPM action
  • Loading branch information
jjatie authored and abhiramvadlapatla committed Dec 21, 2021
1 parent a52e7a5 commit 4498c82
Show file tree
Hide file tree
Showing 17 changed files with 52 additions and 245 deletions.
17 changes: 17 additions & 0 deletions .github/workflows/swift.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Swift

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
build:

runs-on: macos-latest

steps:
- uses: actions/checkout@v2
- name: Build
run: swift build -v
12 changes: 7 additions & 5 deletions Source/Charts/Charts/BarLineChartViewBase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@
// https://github.com/danielgindi/Charts
//

import Foundation
import CoreGraphics
import Foundation

#if !os(OSX)
import UIKit
#if canImport(UIKit)
import UIKit
#elseif canImport(AppKit)
import AppKit
#endif

/// Base-class of LineChart, BarChart, ScatterChart and CandleStickChart.
Expand Down Expand Up @@ -905,7 +907,7 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD
}

#if !os(OSX)
open override func gestureRecognizerShouldBegin(_ gestureRecognizer: UIGestureRecognizer) -> Bool
open override func gestureRecognizerShouldBegin(_ gestureRecognizer: NSUIGestureRecognizer) -> Bool
{
if !super.gestureRecognizerShouldBegin(gestureRecognizer)
{
Expand All @@ -917,7 +919,7 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD
#endif

#if os(OSX)
public func gestureRecognizerShouldBegin(gestureRecognizer: NSGestureRecognizer) -> Bool
public func gestureRecognizerShouldBegin(gestureRecognizer: NSUIGestureRecognizer) -> Bool
{
return nsuiGestureRecognizerShouldBegin(gestureRecognizer)
}
Expand Down
4 changes: 2 additions & 2 deletions Source/Charts/Charts/ChartViewBase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ open class ChartViewBase: NSUIView, ChartDataProvider, AnimatorDelegate
@objc open var noDataTextColor: NSUIColor = .labelOrBlack

/// alignment of the no data text
@objc open var noDataTextAlignment: NSTextAlignment = .left
@objc open var noDataTextAlignment: TextAlignment = .left

/// The renderer object responsible for rendering / drawing the Legend.
@objc open lazy var legendRenderer = LegendRenderer(viewPortHandler: viewPortHandler, legend: legend)
Expand Down Expand Up @@ -276,7 +276,7 @@ open class ChartViewBase: NSUIView, ChartDataProvider, AnimatorDelegate
context.saveGState()
defer { context.restoreGState() }

let paragraphStyle = NSMutableParagraphStyle.default.mutableCopy() as! NSMutableParagraphStyle
let paragraphStyle = MutableParagraphStyle.default.mutableCopy() as! MutableParagraphStyle
paragraphStyle.minimumLineHeight = noDataFont.lineHeight
paragraphStyle.lineBreakMode = .byWordWrapping
paragraphStyle.alignment = noDataTextAlignment
Expand Down
2 changes: 1 addition & 1 deletion Source/Charts/Charts/PieChartView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ open class PieChartView: PieRadarChartViewBase
}
else
{
let paragraphStyle = NSParagraphStyle.default.mutableCopy() as! NSMutableParagraphStyle
let paragraphStyle = ParagraphStyle.default.mutableCopy() as! MutableParagraphStyle
paragraphStyle.lineBreakMode = .byTruncatingTail
paragraphStyle.alignment = .center

Expand Down
2 changes: 1 addition & 1 deletion Source/Charts/Components/Description.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ open class Description: ComponentBase
open var position: CGPoint? = nil

/// The text alignment of the description text. Default RIGHT.
@objc open var textAlign: NSTextAlignment = NSTextAlignment.right
@objc open var textAlign: TextAlignment = TextAlignment.right

/// Font object used for drawing the description text.
@objc open var font: NSUIFont
Expand Down
7 changes: 3 additions & 4 deletions Source/Charts/Components/MarkerView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,14 @@ open class MarkerView: NSUIView, Marker
options: nil)?[0] as? MarkerView
#else

var loadedObjects = NSArray()
let loadedObjectsPointer = AutoreleasingUnsafeMutablePointer<NSArray?>(&loadedObjects)
var loadedObjects: NSArray? = NSArray()

if bundle.loadNibNamed(
NSNib.Name(String(describing: self)),
owner: nil,
topLevelObjects: loadedObjectsPointer)
topLevelObjects: &loadedObjects)
{
return loadedObjects[0] as? MarkerView
return loadedObjects?[0] as? MarkerView
}

return nil
Expand Down
2 changes: 1 addition & 1 deletion Source/Charts/Components/YAxis.swift
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ open class YAxis: AxisBase
@objc open var labelPosition = LabelPosition.outsideChart

/// the alignment of the text in the y-label
@objc open var labelAlignment: NSTextAlignment = .left
@objc open var labelAlignment: TextAlignment = .left

/// the horizontal offset of the y-label
@objc open var labelXOffset: CGFloat = 0.0
Expand Down
218 changes: 0 additions & 218 deletions Source/Charts/Renderers/AxisRendererBase.swift

This file was deleted.

2 changes: 1 addition & 1 deletion Source/Charts/Renderers/BarChartRenderer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,7 @@ open class BarChartRenderer: BarLineScatterCandleBubbleRenderer
}

/// Draws a value at the specified x and y position.
@objc open func drawValue(context: CGContext, value: String, xPos: CGFloat, yPos: CGFloat, font: NSUIFont, align: NSTextAlignment, color: NSUIColor, anchor: CGPoint, angleRadians: CGFloat)
@objc open func drawValue(context: CGContext, value: String, xPos: CGFloat, yPos: CGFloat, font: NSUIFont, align: TextAlignment, color: NSUIColor, anchor: CGPoint, angleRadians: CGFloat)
{
if (angleRadians == 0.0)
{
Expand Down
2 changes: 1 addition & 1 deletion Source/Charts/Renderers/HorizontalBarChartRenderer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ open class HorizontalBarChartRenderer: BarChartRenderer
let barData = dataProvider.barData
else { return }

let textAlign = NSTextAlignment.left
let textAlign = TextAlignment.left

let valueOffsetPlus: CGFloat = 5.0
var posOffset: CGFloat
Expand Down
2 changes: 1 addition & 1 deletion Source/Charts/Renderers/PieChartRenderer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ open class PieChartRenderer: NSObject, DataRenderer

var pt2: CGPoint
var labelPoint: CGPoint
var align: NSTextAlignment
var align: TextAlignment

var line1Radius: CGFloat

Expand Down
4 changes: 2 additions & 2 deletions Source/Charts/Renderers/XAxisRenderer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ open class XAxisRenderer: NSObject, AxisRenderer
{
guard let transformer = self.transformer else { return }

let paraStyle = NSParagraphStyle.default.mutableCopy() as! NSMutableParagraphStyle
let paraStyle = ParagraphStyle.default.mutableCopy() as! MutableParagraphStyle
paraStyle.alignment = .center

let labelAttrs: [NSAttributedString.Key : Any] = [.font: axis.labelFont,
Expand Down Expand Up @@ -453,7 +453,7 @@ open class XAxisRenderer: NSObject, AxisRenderer

let xOffset: CGFloat = limitLine.lineWidth + limitLine.xOffset

let align: NSTextAlignment
let align: TextAlignment
let point: CGPoint

switch limitLine.labelPosition
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ open class XAxisRendererHorizontalBarChart: XAxisRenderer
let xOffset = 4.0 + l.xOffset
let yOffset = l.lineWidth + labelLineHeight + l.yOffset

let align: NSTextAlignment
let align: TextAlignment
let point: CGPoint

switch l.labelPosition
Expand Down
Loading

0 comments on commit 4498c82

Please sign in to comment.