Skip to content

Commit

Permalink
Fix #246 => Optimize AAChartViewDelegate moveover event method
Browse files Browse the repository at this point in the history
  • Loading branch information
AAChartModel committed Sep 1, 2020
1 parent 46b7eb3 commit b72b82b
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions AAInfographics/AAChartCreator/AAChartView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -570,11 +570,30 @@ extension AAChartView: WKScriptMessageHandler {
}

extension AAChartView {
private func getEventMessageModel(messageBody: [String: Any]) -> AAMoveOverEventMessageModel {
private func getEventMessageModel(messageBody: [String: Any]) -> AAMoveOverEventMessageModel {
let eventMessageModel = AAMoveOverEventMessageModel()
eventMessageModel.name = messageBody["name"] as? String
eventMessageModel.x = messageBody["x"] as? Float
eventMessageModel.y = messageBody["y"] as? Float
let x = messageBody["x"]
if x is String {
eventMessageModel.x = Float(x as! String)
} else if x is Int {
eventMessageModel.x = Float(x as! Int)
} else if x is Float {
eventMessageModel.x = (x as! Float)
} else if x is Double {
eventMessageModel.x = Float(x as! Double)
}

let y = messageBody["y"]
if y is String {
eventMessageModel.y = Float(y as! String)
} else if y is Int {
eventMessageModel.y = Float(y as! Int)
} else if y is Float {
eventMessageModel.y = (y as! Float)
} else if y is Double {
eventMessageModel.y = Float(y as! Double)
}
eventMessageModel.category = messageBody["category"] as? String
eventMessageModel.offset = messageBody["offset"] as? [String: Any]
eventMessageModel.index = messageBody["index"] as? Int
Expand Down

0 comments on commit b72b82b

Please sign in to comment.