|
30 | 30 |
|
31 | 31 | */ |
32 | 32 |
|
33 | | -import UIKit |
| 33 | +import Foundation |
34 | 34 |
|
35 | 35 | // MARK: - Configure Chart View Content With AAChartModel |
36 | 36 | @available(iOS 10.0, macCatalyst 13.1, macOS 10.13, *) |
@@ -71,12 +71,16 @@ extension AAChartView { |
71 | 71 | public func aa_drawChartWithChartOptions(_ aaOptions: AAOptions) { |
72 | 72 | if optionsJson == nil { |
73 | 73 | configureOptionsJsonStringWithAAOptions(aaOptions) |
74 | | - let path = BundlePathLoader() |
| 74 | + guard let path = BundlePathLoader() |
75 | 75 | .path(forResource: "AAChartView", |
76 | 76 | ofType: "html", |
77 | | - inDirectory: "AAJSFiles.bundle") |
78 | | - let urlStr = NSURL.fileURL(withPath: path!) |
79 | | - let urlRequest = NSURLRequest(url: urlStr) as URLRequest |
| 77 | + inDirectory: "AAJSFiles.bundle") else { |
| 78 | + // Consider more robust error handling or logging framework for production code |
| 79 | + print("Error: AAChartView.html not found in AAJSFiles.bundle. Chart cannot be loaded.") |
| 80 | + return |
| 81 | + } |
| 82 | + let fileURL = URL(fileURLWithPath: path) // 'path' is a non-optional String here |
| 83 | + let urlRequest = URLRequest(url: fileURL) |
80 | 84 | load(urlRequest) |
81 | 85 | } else { |
82 | 86 | aa_refreshChartWholeContentWithChartOptions(aaOptions) |
@@ -260,15 +264,15 @@ extension AAChartView { |
260 | 264 | /// Show the series element content with index |
261 | 265 | /// |
262 | 266 | /// - Parameter elementIndex: elementIndex element index |
263 | | - public func aa_showTheSeriesElementContentWithSeriesElementIndex(_ elementIndex: NSInteger) { |
| 267 | + public func aa_showTheSeriesElementContentWithSeriesElementIndex(_ elementIndex: Int) { |
264 | 268 | let jsStr = "showTheSeriesElementContentWithIndex('\(elementIndex)');" |
265 | 269 | safeEvaluateJavaScriptString(jsStr) |
266 | 270 | } |
267 | 271 |
|
268 | 272 | /// Hide the series element content with index |
269 | 273 | /// |
270 | 274 | /// - Parameter elementIndex: element index |
271 | | - public func aa_hideTheSeriesElementContentWithSeriesElementIndex(_ elementIndex: NSInteger) { |
| 275 | + public func aa_hideTheSeriesElementContentWithSeriesElementIndex(_ elementIndex: Int) { |
272 | 276 | let jsStr = "hideTheSeriesElementContentWithIndex('\(elementIndex)');" |
273 | 277 | safeEvaluateJavaScriptString(jsStr as String) |
274 | 278 | } |
@@ -313,39 +317,6 @@ extension AAChartView { |
313 | 317 | let jsStr = "redrawWithAnimation('\(animation)')" |
314 | 318 | safeEvaluateJavaScriptString(jsStr) |
315 | 319 | } |
316 | | - |
317 | | -#if os(iOS) |
318 | | - /// Set the chart view content be adaptive to screen rotation with default animation effect |
319 | | - public func aa_adaptiveScreenRotation() { |
320 | | - let aaAnimation = AAAnimation() |
321 | | - .duration(800) |
322 | | - .easing(.easeOutQuart) |
323 | | - aa_adaptiveScreenRotationWithAnimation(aaAnimation) |
324 | | - } |
325 | | - |
326 | | - /// Set the chart view content be adaptive to screen rotation with custom animation effect |
327 | | - /// Refer to https://api.highcharts.com/highcharts#Chart.setSize |
328 | | - /// |
329 | | - /// - Parameter animation: The instance object of AAAnimation |
330 | | - public func aa_adaptiveScreenRotationWithAnimation(_ animation: AAAnimation) { |
331 | | - NotificationCenter.default.addObserver( |
332 | | - forName: UIDevice.orientationDidChangeNotification, |
333 | | - object: nil, |
334 | | - queue: nil) { [weak self] _ in |
335 | | - //Delay execution by 0.01 seconds to prevent incorrect screen width and height obtained when the screen is rotated |
336 | | - DispatchQueue.main.asyncAfter(deadline: .now() + 0.01) { |
337 | | - self?.aa_resizeChart(animation: animation) |
338 | | - } |
339 | | - } |
340 | | - } |
341 | | - |
342 | | - public func aa_resizeChart(animation: AAAnimation) { |
343 | | - let animationJsonStr = animation.toJSON() |
344 | | - let jsFuncStr = "changeChartSize('\(frame.size.width)','\(frame.size.height)','\(animationJsonStr)')" |
345 | | - safeEvaluateJavaScriptString(jsFuncStr) |
346 | | - } |
347 | | -#endif |
348 | | - |
349 | 320 | } |
350 | 321 |
|
351 | 322 |
|
|
0 commit comments