Skip to content

Commit 30160a2

Browse files
committed
Optimize enum type properties ❗❗❗
1 parent ad51c60 commit 30160a2

File tree

8 files changed

+97
-44
lines changed

8 files changed

+97
-44
lines changed

AAChartKitDemo/ChartsDemo/AreasplineChartOptionsVC.m

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ - (AAOptions *)configureComplicatedCustomAreasplineChart {
121121
.useHTMLSet(true)
122122
.backgroundColorSet(@"#1e90ff")
123123
.borderRadiusSet(@5)
124-
.shapeSet(@"callout")
124+
.shapeSet(AAChartDataLabelsShapeTypeCallout)
125125
.formatSet(@"{point.category}<br>{series.name}: {point.y} %")
126126
.styleSet(AAStyle.new
127127
.fontWeightSet(AAChartFontWeightTypeBold)
@@ -131,7 +131,7 @@ - (AAOptions *)configureComplicatedCustomAreasplineChart {
131131
.ySet(@(-75))
132132
.alignSet(AAChartAlignTypeCenter)
133133
.verticalAlignSet(AAChartVerticalAlignTypeTop)
134-
.overflowSet(@"none")
134+
.overflowSet(AAChartDataLabelsOverflowTypeNone)
135135
.cropSet(false)
136136
)
137137
.ySet(@51.5);
@@ -150,7 +150,7 @@ - (AAOptions *)configureComplicatedCustomAreasplineChart {
150150
.useHTMLSet(true)
151151
.backgroundColorSet(AAColor.redColor)
152152
.borderRadiusSet(@5)
153-
.shapeSet(@"callout")
153+
.shapeSet(AAChartDataLabelsShapeTypeCallout)
154154
.formatSet(@"{point.category}<br>{series.name}: {point.y} %")
155155
.styleSet(AAStyle.new
156156
.fontWeightSet(AAChartFontWeightTypeBold)
@@ -160,7 +160,7 @@ - (AAOptions *)configureComplicatedCustomAreasplineChart {
160160
.ySet(@(-75))
161161
.alignSet(AAChartAlignTypeCenter)
162162
.verticalAlignSet(AAChartVerticalAlignTypeTop)
163-
.overflowSet(@"none")
163+
.overflowSet(AAChartDataLabelsOverflowTypeNone)
164164
.cropSet(false)
165165
)
166166
.ySet(@26.5);
@@ -231,13 +231,13 @@ - (AAOptions *)configureComplicatedCustomAreasplineChart2 {
231231
.useHTMLSet(true)
232232
.backgroundColorSet(AARgbaColor(219, 148, 111, 1.0))
233233
.borderRadiusSet(@10)
234-
.shapeSet(@"callout")
234+
.shapeSet(AAChartDataLabelsShapeTypeCallout)
235235
.formatSet(@"{point.category}<br>{series.name}: {point.y} %")
236236
.styleSet(aaDataLabelsStyle)
237237
.ySet(@(-75))
238238
.alignSet(AAChartAlignTypeCenter)
239239
.verticalAlignSet(AAChartVerticalAlignTypeTop)
240-
.overflowSet(@"none")
240+
.overflowSet(AAChartDataLabelsOverflowTypeNone)
241241
.cropSet(false)
242242
)
243243
.ySet(@51.5);
@@ -257,13 +257,13 @@ - (AAOptions *)configureComplicatedCustomAreasplineChart2 {
257257
.useHTMLSet(true)
258258
.backgroundColorSet(AARgbaColor(65, 111, 166, 1.0))
259259
.borderRadiusSet(@10)
260-
.shapeSet(@"callout")
260+
.shapeSet(AAChartDataLabelsShapeTypeCallout)
261261
.formatSet(@"{point.category}<br>{series.name}: {point.y} %")
262262
.styleSet(aaDataLabelsStyle)
263263
.ySet(@(-75))
264264
.alignSet(AAChartAlignTypeCenter)
265265
.verticalAlignSet(AAChartVerticalAlignTypeTop)
266-
.overflowSet(@"none")
266+
.overflowSet(AAChartDataLabelsOverflowTypeNone)
267267
.cropSet(false)
268268
)
269269
.ySet(@26.5);
@@ -272,7 +272,7 @@ - (AAOptions *)configureComplicatedCustomAreasplineChart2 {
272272
AASeriesElement.new
273273
.nameSet(@"空气湿度")
274274
.lineWidthSet(@3)
275-
.zoneAxisSet(@"x")
275+
.zoneAxisSet(AAChartZoneAxisTypeX)
276276
.zonesSet(@[
277277
AAZonesElement.new
278278
.valueSet(@5)
@@ -291,7 +291,7 @@ - (AAOptions *)configureComplicatedCustomAreasplineChart2 {
291291
AASeriesElement.new
292292
.nameSet(@"土壤湿度")
293293
.lineWidthSet(@3)
294-
.zoneAxisSet(@"x")
294+
.zoneAxisSet(AAChartZoneAxisTypeX)
295295
.zonesSet(@[
296296
AAZonesElement.new
297297
.valueSet(@5)
@@ -335,13 +335,13 @@ - (AAOptions *)configureComplicatedCustomAreasplineChart3 {
335335
.useHTMLSet(true)
336336
.backgroundColorSet(AARgbaColor(219, 148, 111, 1.0))
337337
.borderRadiusSet(@10)
338-
.shapeSet(@"callout")
338+
.shapeSet(AAChartDataLabelsShapeTypeCallout)
339339
.formatSet(@"{point.category}<br>{series.name}: {point.y} %")
340340
.styleSet(aaDataLabelsStyle)
341341
.ySet(@(-75))
342342
.alignSet(AAChartAlignTypeCenter)
343343
.verticalAlignSet(AAChartVerticalAlignTypeTop)
344-
.overflowSet(@"none")
344+
.overflowSet(AAChartDataLabelsOverflowTypeNone)
345345
.cropSet(false)
346346
)
347347
.ySet(@34.5);
@@ -361,13 +361,13 @@ - (AAOptions *)configureComplicatedCustomAreasplineChart3 {
361361
.useHTMLSet(true)
362362
.backgroundColorSet(AARgbaColor(65, 111, 166, 1.0))
363363
.borderRadiusSet(@10)
364-
.shapeSet(@"callout")
364+
.shapeSet(AAChartDataLabelsShapeTypeCallout)
365365
.formatSet(@"{point.category}<br>{series.name}: {point.y} %")
366366
.styleSet(aaDataLabelsStyle)
367367
.ySet(@(-75))
368368
.alignSet(AAChartAlignTypeCenter)
369369
.verticalAlignSet(AAChartVerticalAlignTypeTop)
370-
.overflowSet(@"none")
370+
.overflowSet(AAChartDataLabelsOverflowTypeNone)
371371
.cropSet(false)
372372
)
373373
.ySet(@14.5);
@@ -376,7 +376,7 @@ - (AAOptions *)configureComplicatedCustomAreasplineChart3 {
376376
AASeriesElement.new
377377
.nameSet(@"空气湿度")
378378
.lineWidthSet(@3)
379-
.zoneAxisSet(@"x")
379+
.zoneAxisSet(AAChartZoneAxisTypeX)
380380
.zonesSet(@[
381381
AAZonesElement.new
382382
.valueSet(@3)
@@ -395,7 +395,7 @@ - (AAOptions *)configureComplicatedCustomAreasplineChart3 {
395395
AASeriesElement.new
396396
.nameSet(@"土壤湿度")
397397
.lineWidthSet(@3)
398-
.zoneAxisSet(@"x")
398+
.zoneAxisSet(AAChartZoneAxisTypeX)
399399
.zonesSet(@[
400400
AAZonesElement.new
401401
.valueSet(@3)

AAChartKitDemo/ChartsDemo/CustomStyleChartVC.m

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ - (AAChartModel *)configureMixedLineChart {
255255
AASeriesElement.new
256256
.nameSet(@"本专业")
257257
.dataSet(@[@45, @88, @49, @43, @65, @56, @47, @28, @49, @44, @89, @55])
258-
.zoneAxisSet(@"x")
258+
.zoneAxisSet(AAChartZoneAxisTypeX)
259259
.colorSet((id)AAGradientColor.freshPapayaColor)
260260
.lineWidthSet(@5)
261261
.zonesSet(@[
@@ -364,7 +364,7 @@ - (AAChartModel *)configureXAxisHaveAAZonesElementChart {
364364
.nameSet(@"2017")
365365
.dataSet(@[@7.0, @6.9, @2.5, @14.5, @18.2, @21.5, @5.2, @26.5, @23.3, @45.3, @13.9, @9.6])
366366
.lineWidthSet(@5)
367-
.zoneAxisSet(@"x")
367+
.zoneAxisSet(AAChartZoneAxisTypeX)
368368
.zonesSet(@[
369369
AAZonesElement.new
370370
.valueSet(@5)
@@ -423,15 +423,15 @@ - (AAChartModel *)configureStepLineChart {
423423
AASeriesElement.new
424424
.nameSet(@"Berlin")
425425
.dataSet(@[@450, @432, @401, @454, @590, @530, @510])
426-
.stepSet(AAChartAlignTypeRight), //折线连接点靠右👉
426+
.stepSet(AAChartLineStepTypeRight), //折线连接点靠右👉
427427
AASeriesElement.new
428428
.nameSet(@"New York")
429429
.dataSet(@[@220, @282, @201, @234, @290, @430, @410])
430-
.stepSet(AAChartAlignTypeCenter),//折线连接点居中
430+
.stepSet(AAChartLineStepTypeCenter),//折线连接点居中
431431
AASeriesElement.new
432432
.nameSet(@"Tokyo")
433433
.dataSet(@[@120, @132, @101, @134, @90, @230, @210])
434-
.stepSet(AAChartAlignTypeLeft),//折线连接点靠左边👈
434+
.stepSet(AAChartLineStepTypeLeft),//折线连接点靠左边👈
435435
]);
436436
}
437437

@@ -852,7 +852,7 @@ - (AAChartModel *)customSpecialStyleDataLabelOfSingleDataElementChart {
852852
.ySet(@(-35))
853853
.alignSet(AAChartAlignTypeCenter)
854854
.verticalAlignSet(AAChartVerticalAlignTypeTop)
855-
.overflowSet(@"none")
855+
.overflowSet(AAChartDataLabelsOverflowTypeNone)
856856
.cropSet(false))
857857
.ySet(@26.5),
858858
@5.2, @26.5, @23.3, @45.3, @13.9, @9.6])
@@ -1008,7 +1008,7 @@ - (AAChartModel *)customNormalStackingChartDataLabelsContentAndStyle {
10081008
.ySet(@-10)
10091009
.formatSet(@"{total} mm")
10101010
.colorSet(AAColor.redColor)
1011-
.shapeSet(@"callout")
1011+
.shapeSet(AAChartDataLabelsShapeTypeCallout)
10121012
.backgroundColorSet(AAColor.whiteColor)
10131013
.borderColorSet(AAColor.redColor)
10141014
.borderRadiusSet(@1)
@@ -1405,7 +1405,7 @@ - (AAChartModel *)configureMaxAndMinDataLabelsForChart {
14051405
AADataLabels *aaDataLabels = AADataLabels.new
14061406
.enabledSet(true)
14071407
.formatSet(@"{y} 美元")
1408-
.shapeSet(@"callout")
1408+
.shapeSet(AAChartDataLabelsShapeTypeCallout)
14091409
.styleSet(AAStyleColorSizeWeight(AAColor.redColor, 15, AAChartFontWeightTypeBold))
14101410
.backgroundColorSet(AAColor.whiteColor)// white color
14111411
.borderColorSet(AAColor.redColor)// red color
@@ -1646,7 +1646,7 @@ - (AAChartModel *)customLineChartWithColorfulMarkersAndLines {
16461646
.ySet(@256.0)
16471647
.colorSet(AAColor.redColor)
16481648
])
1649-
.zoneAxisSet(@"x")
1649+
.zoneAxisSet(AAChartZoneAxisTypeX)
16501650
.zonesSet(@[
16511651
AAZonesElement.new
16521652
.valueSet(@1)
@@ -1696,7 +1696,7 @@ - (AAChartModel *)customLineChartWithColorfulMarkersAndLines2 {
16961696
.ySet(@2048)
16971697
.colorSet(AARgbaColor(30, 144, 255, 1.0)),
16981698
])
1699-
.zoneAxisSet(@"x")
1699+
.zoneAxisSet(AAChartZoneAxisTypeX)
17001700
.zonesSet(@[
17011701
AAZonesElement.new
17021702
.valueSet(@1)
@@ -1724,7 +1724,7 @@ - (AAChartModel *)customLineChartWithColorfulMarkersAndLines2 {
17241724
.ySet(@2048)
17251725
.colorSet(AARgbaColor(255, 0, 0, 1.0)),
17261726
])
1727-
.zoneAxisSet(@"x")
1727+
.zoneAxisSet(AAChartZoneAxisTypeX)
17281728
.zonesSet(@[
17291729
AAZonesElement.new
17301730
.valueSet(@1)
@@ -1752,7 +1752,7 @@ - (AAChartModel *)customLineChartWithColorfulMarkersAndLines2 {
17521752
.ySet(@2048)
17531753
.colorSet(AARgbaColor(255, 215, 0, 1.0)),
17541754
])
1755-
.zoneAxisSet(@"x")
1755+
.zoneAxisSet(AAChartZoneAxisTypeX)
17561756
.zonesSet(@[
17571757
AAZonesElement.new
17581758
.valueSet(@1)
@@ -1780,7 +1780,7 @@ - (AAChartModel *)customLineChartWithColorfulMarkersAndLines2 {
17801780
.ySet(@2048)
17811781
.colorSet(AARgbaColor(50, 205, 50, 1.0)),
17821782
])
1783-
.zoneAxisSet(@"x")
1783+
.zoneAxisSet(AAChartZoneAxisTypeX)
17841784
.zonesSet(@[
17851785
AAZonesElement.new
17861786
.valueSet(@1)
@@ -1808,7 +1808,7 @@ - (AAChartModel *)customLineChartWithColorfulMarkersAndLines2 {
18081808
.ySet(@2048)
18091809
.colorSet(AARgbaColor(138, 43, 226, 1.0)),
18101810
])
1811-
.zoneAxisSet(@"x")
1811+
.zoneAxisSet(AAChartZoneAxisTypeX)
18121812
.zonesSet(@[
18131813
AAZonesElement.new
18141814
.valueSet(@1)
@@ -2103,7 +2103,7 @@ - (AAChartModel *)customAreasplineChartWithColorfulGradientColorZones {
21032103
AASeriesElement.new
21042104
.nameSet(@"空气湿度")
21052105
.lineWidthSet(@6)
2106-
.zoneAxisSet(@"x")
2106+
.zoneAxisSet(AAChartZoneAxisTypeX)
21072107
.zonesSet(@[
21082108
AAZonesElement.new
21092109
.valueSet(@2)
@@ -2144,13 +2144,13 @@ - (AAChartModel *)customAreasplineChartWithColorfulGradientColorZones {
21442144
.useHTMLSet(true)
21452145
.backgroundColorSet(AARgbaColor(65, 111, 166, 1.0))
21462146
.borderRadiusSet(@10)
2147-
.shapeSet(@"callout")
2147+
.shapeSet(AAChartDataLabelsShapeTypeCallout)
21482148
.formatSet(@"{point.category}<br>{series.name}: {point.y} %")
21492149
.styleSet(AAStyleColorSizeWeight(AAColor.whiteColor, 12, AAChartFontWeightTypeBold))
21502150
.xSet(@-80).ySet(@(5))
21512151
.alignSet(AAChartAlignTypeCenter)
21522152
.verticalAlignSet(AAChartVerticalAlignTypeTop)
2153-
.overflowSet(@"none")
2153+
.overflowSet(AAChartDataLabelsOverflowTypeNone)
21542154
.cropSet(false))
21552155
.ySet(@85.3)]),
21562156
]);

AAChartKitDemo/ChartsDemo/DataLabelsOptionsVC.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ - (AAOptions *)adjustChartDataLabelsStyle {
6565
.colorSet(AAColor.redColor)
6666
.backgroundColorSet(AAColor.whiteColor)
6767
.borderColorSet(AAColor.redColor)
68-
.shapeSet(@"callout")
68+
.shapeSet(AAChartDataLabelsShapeTypeCallout)
6969
.borderRadiusSet(@1)
7070
.borderWidthSet(@1);
7171

@@ -143,7 +143,7 @@ - (AAOptions *)customizeEveryDataLabelBySinglely {
143143
.verticalAlignSet(AAChartVerticalAlignTypeMiddle)
144144
.backgroundColorSet(AAColor.whiteColor)// white color
145145
.borderColorSet(AAColor.redColor)// red color
146-
.shapeSet(@"callout")
146+
.shapeSet(AAChartDataLabelsShapeTypeCallout)
147147
.borderRadiusSet(@1.5)
148148
.borderWidthSet(@1.3)
149149
.styleSet(AAStyleColorSizeWeight(AAColor.redColor, 15, AAChartFontWeightTypeBold))
@@ -181,7 +181,7 @@ - (AAOptions *)configureStackingColumnChartDataLabelsOverflow {
181181
.enabledSet(YES)
182182
.allowOverlapSet(YES)
183183
.cropSet(false)
184-
.overflowSet(@"none")
184+
.overflowSet(AAChartDataLabelsOverflowTypeNone)
185185
.styleSet(AAStyle.new
186186
.colorSet(AAColor.blackColor)
187187
.fontSizeSet(@"11px")

AAChartKitDemo/ChartsDemo/DrawChartWithAAOptionsVC.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ - (AAOptions *)configureTheNoGapColunmChart {
285285
.ySet(@-10)
286286
.formatSet(@" {y} 美元 ")
287287
.backgroundColorSet(@"rgba(0, 0, 0, 0.75)")
288-
.shapeSet(@"callout")
288+
.shapeSet(AAChartDataLabelsShapeTypeCallout)
289289
.styleSet(AAStyle.new
290290
.colorSet(AAColor.whiteColor)
291291
.textOutlineSet(@"none"));

AAChartKitLib/AAChartCreator/AASeriesElement.h

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,16 @@
3434

3535
@class AAMarker, AADataLabels, AATooltip, AAStates, AAShadow, AAZonesElement, AADataSorting;
3636

37+
typedef NSString * AAChartZoneAxisType;
38+
typedef NSString * AAChartLineStepType;
39+
40+
AACHARTKIT_EXTERN AAChartZoneAxisType const AAChartZoneAxisTypeX;
41+
AACHARTKIT_EXTERN AAChartZoneAxisType const AAChartZoneAxisTypeY;
42+
43+
AACHARTKIT_EXTERN AAChartLineStepType const AAChartLineStepTypeLeft;
44+
AACHARTKIT_EXTERN AAChartLineStepType const AAChartLineStepTypeCenter;
45+
AACHARTKIT_EXTERN AAChartLineStepType const AAChartLineStepTypeRight;
46+
3747
@interface AASeriesElement : NSObject
3848

3949
AAPropStatementAndPropSetFuncStatement(copy, AASeriesElement, NSString *, type)
@@ -69,7 +79,7 @@ AAPropStatementAndPropSetFuncStatement(strong, AASeriesElement, AAStates *, stat
6979
AAPropStatementAndPropSetFuncStatement(assign, AASeriesElement, BOOL , showInLegend) //Whether to display this particular series or series type in the legend. The default value is true for standalone series, false for linked series. 默认是:true.
7080
AAPropStatementAndPropSetFuncStatement(assign, AASeriesElement, BOOL , visible) //数据列是否显示的状态,可以通过 series.show()、series.hide()、series.setVisible 来改变这个属性
7181
AAPropStatementAndPropSetFuncStatement(strong, AASeriesElement, NSArray<AAZonesElement *>*, zones)
72-
AAPropStatementAndPropSetFuncStatement(copy, AASeriesElement, NSString *, zoneAxis) //Defines the Axis on which the zones are applied. 默认是:y.
82+
AAPropStatementAndPropSetFuncStatement(copy, AASeriesElement, AAChartZoneAxisType, zoneAxis) //Defines the Axis on which the zones are applied. 默认是:y.
7383
AAPropStatementAndPropSetFuncStatement(strong, AASeriesElement, AAShadow *, shadow) //数据列的阴影效果。从 2.3 开始阴影可以配置成包含 color、offsetX、offsetY、opacity 和 width 属性的对象形式。 默认是:false
7484
AAPropStatementAndPropSetFuncStatement(copy, AASeriesElement, NSString *, stack)
7585
AAPropStatementAndPropSetFuncStatement(strong, AASeriesElement, AATooltip*, tooltip)

AAChartKitLib/AAChartCreator/AASeriesElement.m

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,13 @@
3333

3434
#import "AASeriesElement.h"
3535

36+
AAChartZoneAxisType const AAChartZoneAxisTypeX = @"x";
37+
AAChartZoneAxisType const AAChartZoneAxisTypeY = @"y";
38+
39+
AAChartLineStepType const AAChartLineStepTypeLeft = @"left";
40+
AAChartLineStepType const AAChartLineStepTypeCenter = @"center";
41+
AAChartLineStepType const AAChartLineStepTypeRight = @"right";
42+
3643
@implementation AASeriesElement
3744

3845
- (instancetype)init {
@@ -78,7 +85,7 @@ - (instancetype)init {
7885
AAPropSetFuncImplementation(AASeriesElement, BOOL , showInLegend) //Whether to display this particular series or series type in the legend. The default value is true for standalone series, false for linked series. 默认是:true.
7986
AAPropSetFuncImplementation(AASeriesElement, BOOL , visible) //数据列是否显示的状态,可以通过 series.show()、series.hide()、series.setVisible 来改变这个属性
8087
AAPropSetFuncImplementation(AASeriesElement, NSArray<AAZonesElement *>*, zones)
81-
AAPropSetFuncImplementation(AASeriesElement, NSString *, zoneAxis) //Defines the Axis on which the zones are applied. 默认是:y.
88+
AAPropSetFuncImplementation(AASeriesElement, AAChartZoneAxisType, zoneAxis) //Defines the Axis on which the zones are applied. 默认是:y.
8289
AAPropSetFuncImplementation(AASeriesElement, AAShadow *, shadow) //数据列的阴影效果。从 2.3 开始阴影可以配置成包含 color、offsetX、offsetY、opacity 和 width 属性的对象形式。 默认是:false
8390
AAPropSetFuncImplementation(AASeriesElement, NSString *, stack)
8491
AAPropSetFuncImplementation(AASeriesElement, AATooltip*, tooltip)

0 commit comments

Comments
 (0)