Skip to content

Commit 801cdc8

Browse files
committed
Fix #288 => Add shouldPrintOptionsJSON property for AAChartView
1 parent 0b7e265 commit 801cdc8

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

AAInfographics/AAChartCreator/AAChartView.swift

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,10 @@ public class AAChartView: WKWebView {
176176

177177
private var optionsJson: String?
178178

179+
#if DEBUG
180+
public var shouldPrintOptionsJSON: Bool = true
181+
#endif
182+
179183
// MARK: - Initialization
180184
override private init(frame: CGRect, configuration: WKWebViewConfiguration) {
181185
super.init(frame: frame, configuration: configuration)
@@ -295,16 +299,18 @@ public class AAChartView: WKWebView {
295299
}
296300

297301
#if DEBUG
298-
let modelJsonDic = aaOptions.toDic()
299-
let data = try? JSONSerialization.data(withJSONObject: modelJsonDic, options: .prettyPrinted)
300-
if data != nil {
301-
let prettyPrintedModelJson = String(data: data!, encoding: String.Encoding.utf8)
302-
print("""
302+
if shouldPrintOptionsJSON {
303+
let modelJsonDic = aaOptions.toDic()
304+
let data = try? JSONSerialization.data(withJSONObject: modelJsonDic, options: .prettyPrinted)
305+
if data != nil {
306+
let prettyPrintedModelJson = String(data: data!, encoding: String.Encoding.utf8)
307+
print("""
303308
304309
-----------🖨🖨🖨 console log AAOptions JSON information of AAChartView 🖨🖨🖨-----------:
305310
\(prettyPrintedModelJson!)
306311
307312
""")
313+
}
308314
}
309315
#endif
310316

AAInfographicsDemo/Demo/AAChartModel/ViewController/BasicChartVC.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ class BasicChartVC: UIViewController {
5050
chartView.isScrollEnabled = false//Disable chart content scrolling
5151
chartView.isClearBackgroundColor = true
5252
chartView.delegate = self as AAChartViewDelegate
53+
#if DEBUG
54+
chartView.shouldPrintOptionsJSON = false
55+
#endif
5356
view.addSubview(chartView)
5457
// Chart view constraints
5558
NSLayoutConstraint.activate([

0 commit comments

Comments
 (0)