Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
AAChartModel committed Jan 4, 2024
2 parents fc4a08f + 6e74e8a commit eac4aa1
Show file tree
Hide file tree
Showing 24 changed files with 2,901 additions and 148 deletions.
100 changes: 0 additions & 100 deletions AAInfographics/AAChartCreator/AAChartModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -498,104 +498,4 @@ public class AAChartModel: AAObject {
borderRadius = 0
markerRadius = 5 //The radius of the polyline connection point. If the default value is set to 0, then this is equivalent to not displaying.
}



@available(*, unavailable, message: "please use titleStyle instead of it")
public var titleFontColor: String? //The chart title font color
@available(*, unavailable, message: "please use titleStyle instead of it")
public var titleFontSize: Float? //The chart title font size
@available(*, unavailable, message: "please use titleStyle instead of it")
public var titleFontWeight: AAChartFontWeightType? //The chart font weight

@available(*, unavailable, message: "please use subtitleStyle instead of it")
public var subtitleFontColor: String? //The chart subtitle font color
@available(*, unavailable, message: "please use subtitleStyle instead of it")
public var subtitleFontSize: Float? //The chart subtitle font size
@available(*, unavailable, message: "please use subtitleStyle instead of it")
public var subtitleFontWeight: AAChartFontWeightType? //The chart subtitle font weight

@available(*, unavailable, message: "please use dataLabelsStyle instead of it")
public var dataLabelsFontColor: String? //The data labels font color
@available(*, unavailable, message: "please use dataLabelsStyle instead of it")
public var dataLabelsFontSize: Float? //The data labels font size
@available(*, unavailable, message: "please use dataLabelsStyle instead of it")
public var dataLabelsFontWeight: AAChartFontWeightType?//The data labels font weight

@available(*, unavailable, message: "please use xAxisLabelsStyle or yAxisLabelsStyle instead of it")
public var axesTextColor: String? //The labels font color of chart x axis and y axis

@available(*, unavailable, message: "This property is useless now, please remove it directly")
public var touchEventEnabled: Bool? //Support touch event call back or not


@available(*, unavailable, message: "please use titleStyle instead of it")
public func titleFontColor(_ prop: String) -> AAChartModel {
// titleFontColor = prop
return self
}

@available(*, unavailable, message: "please use titleStyle instead of it")
public func titleFontSize(_ prop: Float?) -> AAChartModel {
// titleFontSize = prop
return self
}

@available(*, unavailable, message: "please use titleStyle instead of it")
public func titleFontWeight(_ prop: AAChartFontWeightType) -> AAChartModel {
// titleFontWeight = prop
return self
}


@available(*, unavailable, message: "please use subtitleStyle instead of it")
public func subtitleFontColor(_ prop: String) -> AAChartModel {
// subtitleFontColor = prop
return self
}

@available(*, unavailable, message: "please use subtitleStyle instead of it")
public func subtitleFontSize(_ prop: Float?) -> AAChartModel {
// subtitleFontSize = prop
return self
}

@available(*, unavailable, message: "please use subtitleStyle instead of it")
public func subtitleFontWeight(_ prop: AAChartFontWeightType) -> AAChartModel {
// subtitleFontWeight = prop
return self
}


@available(*, unavailable, message: "please use dataLabelsStyle instead of it")
public func dataLabelsFontColor(_ prop: String) -> AAChartModel {
// dataLabelsFontColor = prop
return self
}

@available(*, unavailable, message: "please use dataLabelsStyle instead of it")
public func dataLabelsFontSize(_ prop: Float?) -> AAChartModel {
// dataLabelsFontSize = prop
return self
}

@available(*, unavailable, message: "please use dataLabelsStyle instead of it")
public func dataLabelsFontWeight(_ prop: AAChartFontWeightType) -> AAChartModel {
// dataLabelsFontWeight = prop
return self
}

@available(*, unavailable, message: "please use xAxisLabelsStyle or yAxisLabelsStyle instead of it")
public func axesTextColor(_ prop: String) -> AAChartModel {
// axesTextColor = prop
return self
}

@available(*, unavailable, message: "This setter function is useless now, please remove it directly")
public func touchEventEnabled(_ prop: Bool) -> AAChartModel {
// touchEventEnabled = prop
return self
}


}
25 changes: 13 additions & 12 deletions AAInfographics/AAChartCreator/AAChartView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,6 @@

import WebKit

let kUserContentMessageNameClick = "click"
let kUserContentMessageNameMouseOver = "mouseover"

@available(iOS 10.0, macCatalyst 13.1, macOS 10.13, *)
@objc public protocol AAChartViewDelegate: NSObjectProtocol {
@objc optional func aaChartViewDidFinishLoad(_ aaChartView: AAChartView)
Expand Down Expand Up @@ -79,6 +76,9 @@ public class AALeakAvoider : NSObject, WKScriptMessageHandler {

@available(iOS 10.0, macCatalyst 13.1, macOS 10.13, *)
public class AAChartView: WKWebView {
let kUserContentMessageNameClick = "click"
let kUserContentMessageNameMouseOver = "mouseover"

private var clickEventEnabled: Bool?
private var touchEventEnabled: Bool?

Expand All @@ -105,8 +105,6 @@ public class AAChartView: WKWebView {

// MARK: - Setter Method
#if os(iOS)
@available(*, unavailable, message: "This property was renamed, please use isScrollEnabled instead of it")
public var scrollEnabled: Bool?
public var isScrollEnabled: Bool? {
willSet {
scrollView.isScrollEnabled = newValue!
Expand Down Expand Up @@ -390,7 +388,7 @@ extension AAChartView {
extension AAChartView {
/// A common chart update function
/// (you can update any chart element) to open, close, delete, add, resize, reformat, etc. elements in the chart.
/// Refer to https://api.highcharts.com.cn/highcharts#Chart.update
/// Refer to https://api.highcharts.com/highcharts#Chart.update
///
/// It should be noted that when updating the array configuration,
/// for example, when updating configuration attributes including arrays such as xAxis, yAxis, series, etc., the updated data will find existing objects based on id and update them. If no id is configured or passed If the id does not find the corresponding object, the first element of the array is updated. Please refer to this example for details.
Expand Down Expand Up @@ -452,7 +450,7 @@ extension AAChartView {

/// Add a new point to the data column after the chart has been rendered.
/// The new point can be the last point, or it can be placed in the corresponding position given the X value (first, middle position, depending on the x value)
/// Refer to https://api.highcharts.com.cn/highcharts#Series.addPoint
/// Refer to https://api.highcharts.com/highcharts#Series.addPoint
///
/// - Parameter elementIndex: The specific series element
/// - Parameter options: The configuration of the data point can be a single value, indicating the y value of the data point; it can also be an array containing x and y values; it can also be an object containing detailed data point configuration. For detailed configuration, see series.data.
Expand Down Expand Up @@ -501,7 +499,7 @@ extension AAChartView {
}

/// Add a new series element to the chart after the chart has been rendered.
/// Refer to https://api.highcharts.com.cn/highcharts#Chart.addSeries
/// Refer to https://api.highcharts.com/highcharts#Chart.addSeries
///
/// - Parameter element: chart series element
public func aa_addElementToChartSeries(element: AASeriesElement) {
Expand All @@ -512,7 +510,7 @@ extension AAChartView {
}

/// Remove a specific series element from the chart after the chart has been rendered.
/// Refer to https://api.highcharts.com.cn/highcharts#Series.remove
/// Refer to https://api.highcharts.com/highcharts#Series.remove
///
/// - Parameter elementIndex: chart series element index
public func aa_removeElementFromChartSeries(elementIndex: Int) {
Expand Down Expand Up @@ -583,16 +581,19 @@ extension AAChartView {
}

/// Set the chart view content be adaptive to screen rotation with custom animation effect
/// Refer to https://api.highcharts.com.cn/highcharts#Chart.setSize
/// Refer to https://api.highcharts.com/highcharts#Chart.setSize
///
/// - Parameter animation: The instance object of AAAnimation
public func aa_adaptiveScreenRotationWithAnimation(_ animation: AAAnimation) {
NotificationCenter.default.addObserver(
forName: UIDevice.orientationDidChangeNotification,
object: nil,
queue: nil) { [weak self] _ in
self?.handleDeviceOrientationChangeEventWithAnimation(animation)
}
//Delay execution by 0.01 seconds to prevent incorrect screen width and height obtained when the screen is rotated
DispatchQueue.main.asyncAfter(deadline: .now() + 0.01) {
self?.handleDeviceOrientationChangeEventWithAnimation(animation)
}
}
}

private func handleDeviceOrientationChangeEventWithAnimation(_ animation: AAAnimation) {
Expand Down
15 changes: 14 additions & 1 deletion AAInfographics/AAChartCreator/AASeriesElement.swift
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,14 @@ public class AASeriesElement: AAObject {
public var stack: String?
public var tooltip: AATooltip?
public var pointPlacement: Any?
public var pointPadding: Float?
public var enableMouseTracking: Bool?
public var dataSorting: AADataSorting?
public var reversed: Bool? //Only useful for pyramid chart and funnel chart
public var id: String?
public var connectNulls: Bool? //Whether to connect a graph line across null points. default value:false.
public var enabledCrosshairs: Bool?

public var jitter: AAJitter? //Only useful for scatter chart and bubble chart

@discardableResult
public func type(_ prop: AAChartType) -> AASeriesElement {
Expand Down Expand Up @@ -304,6 +305,12 @@ public class AASeriesElement: AAObject {
pointPlacement = prop
return self
}

@discardableResult
public func pointPadding(_ prop: Float) -> AASeriesElement {
pointPadding = prop
return self
}

@discardableResult
public func enableMouseTracking(_ prop: Bool) -> AASeriesElement {
Expand Down Expand Up @@ -340,6 +347,12 @@ public class AASeriesElement: AAObject {
connectNulls = prop
return self
}

@discardableResult
public func jitter(_ prop: AAJitter) -> AASeriesElement {
jitter = prop
return self
}

public override init() {
}
Expand Down
26 changes: 24 additions & 2 deletions AAInfographics/AAOptionsModel/AAAxis.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ public class AAAxis: AAObject {
public var plotBands: [AAPlotBandsElement]?
public var plotLines: [AAPlotLinesElement]?
public var categories: [String]?
public var reversed: Bool?
public var reversed: Bool? //Whether to reverse the axis so that the highest number is closest to the origin. If the chart is inverted, the XOrY-axis is reversed by default.
public var reversedStacks: Bool?
public var lineWidth: Float? // XOrY-axis line width
public var lineColor: String? // XOrY-axis line color
public var linkedTo: Int?
Expand Down Expand Up @@ -90,9 +91,12 @@ public class AAAxis: AAObject {
public var tickInterval: Float? // Number of ticks on the X or Y axis (set the X or Y axis content every few points:
public var tickmarkPlacement: String? // This parameter is only valid for the classification axis. When the value is on, the tick mark will be displayed above the classification; when the value is between, the tick mark will be displayed between the two classifications. When tickInterval is 1, the default is between, otherwise it is on. The default is: null.
public var tickWidth: Float? // The width of the axis tick marks. When set to 0, tick marks are not displayed.
public var tickLength: Float? /// The length of the axis tick marks. The default is: 10.
public var tickLength: Float? // The length of the axis tick marks. The default is: 10.
public var tickPosition: String? // Position of the tick line relative to the axis line. Available values ​​are "inside" and "outside", which represent the inside and outside of the axis line, respectively. The default is: "outside".
public var tickPositions: [Any]? // Custom XOrY-axis coordinates
public var height: Any? //number | string
public var top: Any? //number | string


@discardableResult
public func allowDecimals(_ prop: Bool?) -> Self {
Expand Down Expand Up @@ -154,6 +158,12 @@ public class AAAxis: AAObject {
return self
}

@discardableResult
public func reversedStacks(_ prop: Bool?) -> Self {
reversedStacks = prop
return self
}

@discardableResult
public func lineWidth(_ prop: Float?) -> Self {
lineWidth = prop
Expand Down Expand Up @@ -376,6 +386,18 @@ public class AAAxis: AAObject {
return self
}

@discardableResult
public func height(_ prop: Any?) -> Self {
height = prop
return self
}

@discardableResult
public func top(_ prop: Any?) -> Self {
top = prop
return self
}

public override init() {

}
Expand Down
14 changes: 14 additions & 0 deletions AAInfographics/AAOptionsModel/AABoxplot.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,12 @@ import Foundation
public class AABoxplot: AAObject {
public var boxDashStyle: String?
public var fillColor: Any?
public var grouping: Bool?//Whether to group non-stacked columns or to let them render independent of each other. Non-grouped columns will be laid out individually and overlap each other. default:true.
public var lineWidth: Float?
public var medianColor: String?
public var medianDashStyle: String?
public var medianWidth: Float?
public var pointRange: Float?
public var stemColor: String?
public var stemDashStyle: String?
public var stemWidth: Float?
Expand All @@ -58,6 +60,12 @@ public class AABoxplot: AAObject {
fillColor = prop
return self
}

@discardableResult
public func grouping(_ prop: Bool?) -> AABoxplot {
grouping = prop
return self
}

@discardableResult
public func lineWidth(_ prop: Float?) -> AABoxplot {
Expand All @@ -83,6 +91,12 @@ public class AABoxplot: AAObject {
return self
}

@discardableResult
public func pointRange(_ prop: Float?) -> AABoxplot {
pointRange = prop
return self
}

@discardableResult
public func stemColor(_ prop: String?) -> AABoxplot {
stemColor = prop
Expand Down
7 changes: 7 additions & 0 deletions AAInfographics/AAOptionsModel/AAChart.swift
Original file line number Diff line number Diff line change
Expand Up @@ -293,11 +293,18 @@ public class AAResetZoomButton: AAObject {
}

public class AAChartEvents: AAObject {
public var click: String?
public var load: String?
public var redraw: String?
public var render: String?
public var selection: String?


@discardableResult
public func click(_ prop: String?) -> AAChartEvents {
click = prop?.aa_toPureJSString()
return self
}

@discardableResult
public func load(_ prop: String?) -> AAChartEvents {
Expand Down
Loading

0 comments on commit eac4aa1

Please sign in to comment.