Skip to content

Commit 949a962

Browse files
committed
Add configureGlobalDefaultOptions for AABaseChartVC
1 parent 3d1a3c8 commit 949a962

File tree

1 file changed

+44
-68
lines changed

1 file changed

+44
-68
lines changed

AAInfographicsDemo/Demo/AdditionalContent2/AABaseChartVC.swift

Lines changed: 44 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -217,14 +217,52 @@ class AABaseChartVC: UIViewController {
217217
}
218218
if (chartConfiguration is AAChartModel) {
219219
let aaChartModel = chartConfiguration as! AAChartModel
220-
aaChartView?.aa_drawChartWithChartModel(aaChartModel)
220+
let aaOptions = aaChartModel.aa_toAAOptions()
221+
configureGlobalDefaultOptions(aaOptions)
222+
aaChartView?.aa_drawChartWithChartOptions(aaOptions)
221223
} else if (chartConfiguration is AAOptions) {
222224
let aaOptions = chartConfiguration as! AAOptions
225+
configureGlobalDefaultOptions(aaOptions)
223226
// aaOptions.touchEventEnabled = true
224227
aaChartView?.aa_drawChartWithChartOptions(aaOptions)
225228
}
226229
}
227230

231+
fileprivate func configureGlobalDefaultOptions(_ aaOptions: AAOptions) {
232+
aaOptions.credits?
233+
.enabled(true)
234+
.text("https://github.com/AAChartModel/AAChartKit")
235+
.href("https://github.com/AAChartModel/AAChartKit")
236+
.style(AAStyle()
237+
.color(AAColor.red)
238+
.fontSize(9))
239+
240+
aaOptions.defaultOptions = AALang()
241+
.noData("暂无数据")
242+
.resetZoom("点击重置缩放比例")
243+
244+
aaOptions.chart?.pinchType = nil
245+
246+
aaOptions.chart?.zooming = AAZooming()
247+
.resetButton(AAResetButton()
248+
.theme([
249+
"fill": "yellow",
250+
"stroke": "green",
251+
"r": 3,
252+
"states": [
253+
"hover": [
254+
"fill": "#ff0000",
255+
"style": [
256+
"color": "white"
257+
]
258+
]
259+
]
260+
]))
261+
.singleTouch(true)
262+
.type(.x)
263+
.pinchType(.x)
264+
}
265+
228266
func refreshChartWithChartConfiguration() {
229267
var chartConfiguration = chartConfigurationWithSelectedIndex(selectedIndex)
230268
if chartConfiguration == nil {
@@ -239,76 +277,14 @@ class AABaseChartVC: UIViewController {
239277
}
240278
if (chartConfiguration is AAChartModel) {
241279
let aaChartModel = chartConfiguration as! AAChartModel
242-
aaChartView?.aa_refreshChartWholeContentWithChartModel(aaChartModel)
280+
let aaOptions = aaChartModel.aa_toAAOptions()
281+
configureGlobalDefaultOptions(aaOptions)
282+
aaChartView?.aa_refreshChartWholeContentWithChartOptions(aaOptions)
243283
} else if (chartConfiguration is AAOptions) {
244284
let aaOptions = chartConfiguration as! AAOptions
245285
// aaOptions.touchEventEnabled = true
246-
aaOptions.credits?
247-
.enabled(true)
248-
.text("https://github.com/AAChartModel/AAChartKit")
249-
.href("https://github.com/AAChartModel/AAChartKit")
250-
.style(AAStyle()
251-
.color(AAColor.red)
252-
.fontSize(9))
253-
254-
aaOptions.defaultOptions = AALang()
255-
.noData("暂无数据")
256-
.resetZoom("点击重置缩放比例")
257-
/**
258-
public class AAZooming: AAObject {
259-
public var key: String?
260-
public var mouseWheel: AAMouseWheel?
261-
public var pinchType: String?
262-
public var resetButton: AAResetButton?
263-
public var singleTouch: Bool?
264-
public var type: String?
265-
*/
266-
/**
267-
chart: {
268-
zooming: {
269-
type: 'x',
270-
resetButton: {
271-
theme: {
272-
fill: 'yellow',
273-
stroke: 'green',
274-
r: 3,
275-
states: {
276-
hover: {
277-
fill: '#ff0000',
278-
style: {
279-
color: 'white'
280-
}
281-
}
282-
}
283-
}
284-
}
285-
}
286-
},
287-
*/
288-
aaOptions.chart?.zooming = AAZooming()
289-
.resetButton(AAResetButton()
290-
.theme([
291-
"fill": "yellow",
292-
"stroke": "green",
293-
"r": 3,
294-
"states": [
295-
"hover": [
296-
"fill": "#ff0000",
297-
"style": [
298-
"color": "white"
299-
]
300-
]
301-
]
302-
]))
303-
.singleTouch(true)
304-
.type(.x)
305-
.pinchType(.x)
306-
307-
aaOptions.chart?.pinchType = nil
308-
309-
310-
311-
aaChartView?.isScrollEnabled = true
286+
configureGlobalDefaultOptions(aaOptions)
287+
// aaChartView?.isScrollEnabled = true
312288
aaChartView?.aa_refreshChartWholeContentWithChartOptions(aaOptions)
313289
}
314290
}

0 commit comments

Comments
 (0)