Skip to content

Commit be68b68

Browse files
committed
Add more useful functions comments
1 parent ee8a837 commit be68b68

File tree

1 file changed

+51
-6
lines changed

1 file changed

+51
-6
lines changed

AAInfographics/AAChartCreator/AAChartView.swift

Lines changed: 51 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -171,27 +171,31 @@ public class AAChartView: WKWebView {
171171
extension AAChartView {
172172
/// Function of drawing chart view
173173
///
174-
/// - Parameter aaChartModel: The instance object of chart model
174+
/// - Parameter aaChartModel: The instance object of AAChartModel
175175
public func aa_drawChartWithChartModel(_ aaChartModel: AAChartModel) {
176176
let options = AAOptionsConstructor.configureChartOptions(aaChartModel)
177177
aa_drawChartWithChartOptions(options)
178178
}
179179

180-
/// Function of only refresh the chart data
180+
/// Function of only refresh the chart data after the chart has been rendered
181181
///
182-
/// - Parameter chartModel: The instance object of chart model
182+
/// - Parameter chartModel: chart model series array
183183
public func aa_onlyRefreshTheChartDataWithChartModelSeries(_ chartModelSeries: [[String: AnyObject]]) {
184184
aa_onlyRefreshTheChartDataWithChartOptionsSeries(chartModelSeries)
185185
}
186186

187-
/// Function of refreshing whole chart view content
187+
/// Function of refreshing whole chart view content after the chart has been rendered
188188
///
189-
/// - Parameter aaChartModel: The instance object of chart model
189+
/// - Parameter aaChartModel: The instance object of AAChartModel
190190
public func aa_refreshChartWholeContentWithChartModel(_ aaChartModel: AAChartModel) {
191191
let aaOptions = AAOptionsConstructor.configureChartOptions(aaChartModel)
192192
aa_refreshChartWholeContentWithChartOptions(aaOptions)
193193
}
194194

195+
196+
/// Function of drawing chart view
197+
///
198+
/// - Parameter aaOoptions: The instance object of AAOptions model
195199
public func aa_drawChartWithChartOptions(_ aaOoptions: AAOptions) {
196200
if optionsJson == nil {
197201
configureTheJavaScriptStringWithOptions(aaOoptions)
@@ -208,18 +212,37 @@ extension AAChartView {
208212
}
209213
}
210214

215+
216+
/// Function of only refresh the chart data after the chart has been rendered
217+
///
218+
/// - Parameter chartModelSeries: chart model series array
211219
public func aa_onlyRefreshTheChartDataWithChartOptionsSeries(_ chartModelSeries: [[String: AnyObject]]) {
212220
var str = getJSONStringFromArray(array: chartModelSeries)
213221
str = str.replacingOccurrences(of: "\n", with: "") as String
214222
let jsStr = "onlyRefreshTheChartDataWithSeries('\(str)');"
215223
evaluateJavaScriptWithFunctionNameString(jsStr)
216224
}
217225

226+
227+
/// Function of refreshing whole chart view content after the chart has been rendered
228+
///
229+
/// - Parameter aaOptions: The instance object of AAOptions model
218230
public func aa_refreshChartWholeContentWithChartOptions(_ aaOptions: AAOptions) {
219231
configureTheJavaScriptStringWithOptions(aaOptions)
220232
drawChart()
221233
}
222234

235+
/// A common chart update function
236+
/// (you can update any chart element) to open, close, delete, add, resize, reformat, etc. elements in the chart.
237+
/// Refer to https://api.highcharts.com.cn/highcharts#Chart.update
238+
///
239+
/// It should be noted that when updating the array configuration,
240+
/// 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.
241+
///
242+
/// In a responsive configuration, the response of the different rules responsive.rules is actually calling chart.update, and the updated content is configured in chartOptions.
243+
///
244+
/// - Parameter options: A configuration object for the new chart options as defined in the options section of the API.
245+
/// - Parameter redraw: Whether to redraw after updating the chart, the default is true
223246
public func aa_updateChart(options: AAObject, redraw: Bool) {
224247
var classNameStr = options.classNameString
225248
if classNameStr.contains(".") {
@@ -243,14 +266,28 @@ extension AAChartView {
243266
evaluateJavaScriptWithFunctionNameString(jsStr)
244267
}
245268

269+
270+
///Same as the function `func aa_addPointToChartSeriesElement(elementIndex: Int, options: Any, redraw: Bool, shift: Bool, animation: Bool)`
271+
///
246272
public func aa_addPointToChartSeriesElement(elementIndex: Int, options: Any) {
247273
aa_addPointToChartSeriesElement(elementIndex: elementIndex, options: options, shift: true)
248274
}
249275

276+
///Same as the function `func aa_addPointToChartSeriesElement(elementIndex: Int, options: Any, redraw: Bool, shift: Bool, animation: Bool)`
277+
///
250278
public func aa_addPointToChartSeriesElement(elementIndex: Int, options: Any, shift: Bool) {
251279
aa_addPointToChartSeriesElement(elementIndex: elementIndex, options: options, redraw: true, shift: shift, animation: true)
252280
}
253-
281+
282+
/// Add a new point to the data column after the chart has been rendered.
283+
/// 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)
284+
/// Refer to https://api.highcharts.com.cn/highcharts#Series.addPoint
285+
///
286+
/// - Parameter elementIndex: The specific series element
287+
/// - 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.
288+
/// - Parameter redraw: The default is true, whether to redraw the icon after the operation is completed. When you need to add more than one point, it is highly recommended to set redraw to false and manually call chart.redraw() to redraw the chart after all operations have ended.
289+
/// - Parameter shift: The default is false. When this property is true, adding a new point will delete the first point in the data column (that is, keep the total number of data points in the data column unchanged). This property is very useful in the inspection chart
290+
/// - Parameter animation: The default is true, which means that when adding a point, it contains the default animation effect. This parameter can also be passed to the object form containing duration and easing. For details, refer to the animation related configuration.
254291
public func aa_addPointToChartSeriesElement(elementIndex: Int, options: Any, redraw: Bool, shift: Bool, animation: Bool) {
255292
var optionsStr = ""
256293
if options is Int || options is Float || options is Double {
@@ -268,13 +305,21 @@ extension AAChartView {
268305
evaluateJavaScriptWithFunctionNameString(javaScriptStr)
269306
}
270307

308+
/// Add a new series element to the chart after the chart has been rendered.
309+
/// Refer to https://api.highcharts.com.cn/highcharts#Chart.addSeries
310+
///
311+
/// - Parameter element: chart series element
271312
public func aa_addElementToChartSeries(element: AASeriesElement) {
272313
let elementJson = element.toJSON()
273314
let pureElementJsonStr = AAJSStringPurer.pureJavaScriptFunctionString(elementJson!)
274315
let jsStr = "addElementToChartSeriesWithElement('\(pureElementJsonStr)')"
275316
evaluateJavaScriptWithFunctionNameString(jsStr)
276317
}
277318

319+
/// Remove a specific series element from the chart after the chart has been rendered.
320+
/// Refer to https://api.highcharts.com.cn/highcharts#Series.remove
321+
///
322+
/// - Parameter elementIndex: chart series element index
278323
public func aa_removeElementFromChartSeries(elementIndex: Int) {
279324
let jsStr = "removeElementFromChartSeriesWithElementIndex('\(elementIndex)')"
280325
evaluateJavaScriptWithFunctionNameString(jsStr)

0 commit comments

Comments
 (0)