Skip to content

Commit d49a71f

Browse files
committed
Inline chart selection; expose composer methods
Remove the generic +chartConfigurationWithSelectedIndex: API from multiple JSFunctionFor...Composer classes and replace it by exposing individual AAOptions factory methods. Move the selection switch logic into the demo view controllers so each VC calls the specific composer method directly. Also update JSFunctionForAATooltipV2Composer.m to use UIScreen.mainScreen.bounds.size.width for screen width calculation.
1 parent 9b49b2a commit d49a71f

15 files changed

Lines changed: 58 additions & 96 deletions

AAChartKitDemo/Demo/AAOptionsWithJS/Composer/JSFunctionForAAAxisComposer.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ NS_ASSUME_NONNULL_BEGIN
66

77
@interface JSFunctionForAAAxisComposer : NSObject
88

9-
+ (id)chartConfigurationWithSelectedIndex:(NSInteger)selectedIndex;
10-
119
+ (AAOptions *)customYAxisLabels;
1210
+ (AAOptions *)customYAxisLabels2;
1311
+ (AAOptions *)customAreaChartXAxisLabelsTextUnitSuffix1;

AAChartKitDemo/Demo/AAOptionsWithJS/Composer/JSFunctionForAAAxisComposer.m

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -41,27 +41,6 @@ @interface JSFunctionForAAAxisComposer ()
4141

4242
@implementation JSFunctionForAAAxisComposer
4343

44-
+ (id)chartConfigurationWithSelectedIndex:(NSInteger)selectedIndex {
45-
switch (selectedIndex) {
46-
case 0: return [self customYAxisLabels];//自定义Y轴文字
47-
case 1: return [self customYAxisLabels2];//自定义Y轴文字2
48-
case 2: return [self customAreaChartXAxisLabelsTextUnitSuffix1];//自定义X轴文字单位后缀(通过 formatter 函数)
49-
case 3: return [self customAreaChartXAxisLabelsTextUnitSuffix2];//自定义X轴文字单位后缀(不通过 formatter 函数)
50-
case 4: return [self configureTheAxesLabelsFormattersOfDoubleYAxesChart];//配置双 Y 轴图表的 Y 轴文字标签的 Formatter 函数 示例 1
51-
case 5: return [self configureTheAxesLabelsFormattersOfDoubleYAxesChart2];//配置双 Y 轴图表的 Y 轴文字标签的 Formatter 函数 示例 2
52-
case 6: return [self configureTheAxesLabelsFormattersOfDoubleYAxesChart3];//配置双 Y 轴图表的 Y 轴文字标签的 Formatter 函数 示例 3
53-
case 7: return [self customColumnChartXAxisLabelsTextByInterceptTheFirstFourCharacters];//通过截取前四个字符来自定义 X 轴 labels
54-
case 8: return [self customSpiderChartStyle];//自定义蜘蛛🕷🕸图样式
55-
case 9: return [self customizeEveryDataLabelSinglelyByDataLabelsFormatter];//通过 DataLabels 的 formatter 函数来实现单个数据标签🏷自定义
56-
case 10: return [self customXAxisLabelsBeImages];//自定义 X轴 labels 为一组图片
57-
case 11: return [self loadImageForAATooltip];//为自定义 AATooltip 加载图片内容
58-
59-
default:
60-
return nil;
61-
}
62-
}
63-
64-
6544
//https://github.com/AAChartModel/AAChartKit/issues/675
6645
+ (AAOptions *)customYAxisLabels {
6746
AAChartModel *aaChartModel = AAChartModel.new

AAChartKitDemo/Demo/AAOptionsWithJS/Composer/JSFunctionForAALegendComposer.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ NS_ASSUME_NONNULL_BEGIN
66

77
@interface JSFunctionForAALegendComposer : NSObject
88

9-
+ (id)chartConfigurationWithSelectedIndex:(NSInteger)selectedIndex;
10-
119
+ (AAOptions *)disableLegendClickEventForNormalChart;
1210
+ (AAOptions *)disableLegendClickEventForPieChart;
1311
+ (AAOptions *)customLegendItemClickEvent;

AAChartKitDemo/Demo/AAOptionsWithJS/Composer/JSFunctionForAALegendComposer.m

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,6 @@ @interface JSFunctionForAALegendComposer ()
4141

4242
@implementation JSFunctionForAALegendComposer
4343

44-
+ (id)chartConfigurationWithSelectedIndex:(NSInteger)selectedIndex {
45-
switch (selectedIndex) {
46-
case 0: return [self disableLegendClickEventForNormalChart];//禁用普通图表的图例点击事件
47-
case 1: return [self disableLegendClickEventForPieChart];//禁用饼图的图例点击事件
48-
case 2: return [self customLegendItemClickEvent];//自定义图例点击事件
49-
50-
default:
51-
return nil;
52-
}
53-
}
54-
5544
+ (AAOptions *)disableLegendClickEventForNormalChart {
5645
AAChartModel *aaChartModel = AAChartModel.new
5746
.chartTypeSet(AAChartTypeAreaspline)

AAChartKitDemo/Demo/AAOptionsWithJS/Composer/JSFunctionForAAOptionsComposer.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ NS_ASSUME_NONNULL_BEGIN
66

77
@interface JSFunctionForAAOptionsComposer : NSObject
88

9-
+ (id)chartConfigurationWithSelectedIndex:(NSInteger)selectedIndex;
10-
119
+ (AAOptions *)customDoubleXAxesChart;
1210
+ (AAOptions *)disableColumnChartUnselectEventEffectBySeriesPointEventClickFunction;
1311
+ (AAOptions *)customizeEveryDataLabelSinglelyByDataLabelsFormatter;

AAChartKitDemo/Demo/AAOptionsWithJS/Composer/JSFunctionForAAOptionsComposer.m

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,6 @@ @interface JSFunctionForAAOptionsComposer ()
1515

1616
@implementation JSFunctionForAAOptionsComposer
1717

18-
+ (id)chartConfigurationWithSelectedIndex:(NSInteger)selectedIndex {
19-
switch (selectedIndex) {
20-
case 0: return [self customDoubleXAxesChart];
21-
case 1: return [self disableColumnChartUnselectEventEffectBySeriesPointEventClickFunction];
22-
case 2: return [self customizeEveryDataLabelSinglelyByDataLabelsFormatter];
23-
case 3: return [self configureColorfulDataLabelsForPieChart];
24-
case 4: return [self customizeCrosshairsStyle];
25-
default:
26-
return nil;
27-
}
28-
}
29-
3018
//https://github.com/AAChartModel/AAChartKit/issues/780
3119
+ (AAOptions *)customDoubleXAxesChart {
3220
AAOptions *aaOptions = AAOptions.new

AAChartKitDemo/Demo/AAOptionsWithJS/Composer/JSFunctionForAATooltipComposer.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ NS_ASSUME_NONNULL_BEGIN
66

77
@interface JSFunctionForAATooltipComposer : NSObject
88

9-
+ (id)chartConfigurationWithSelectedIndex:(NSUInteger)selectedIndex;
10-
119
+ (AAOptions *)customAreaChartTooltipStyleWithSimpleFormatString;
1210
+ (AAOptions *)customAreaChartTooltipStyleWithDifferentUnitSuffix;
1311
+ (AAOptions *)customAreaChartTooltipStyleWithColorfulHtmlLabels;

AAChartKitDemo/Demo/AAOptionsWithJS/Composer/JSFunctionForAATooltipComposer.m

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -38,26 +38,6 @@
3838

3939
@implementation JSFunctionForAATooltipComposer
4040

41-
+ (id)chartConfigurationWithSelectedIndex:(NSUInteger)selectedIndex {
42-
switch (selectedIndex) {
43-
case 0: return [self customAreaChartTooltipStyleWithSimpleFormatString];//简单字符串拼接
44-
case 1: return [self customAreaChartTooltipStyleWithDifferentUnitSuffix];//自定义不同单位后缀
45-
case 2: return [self customAreaChartTooltipStyleWithColorfulHtmlLabels];//自定义多彩颜色文字
46-
case 3: return [self customLineChartTooltipStyleWhenValueBeZeroDoNotShow];//值为0时,在tooltip中不显示
47-
case 4: return [self customStackedAndGroupedColumnChartTooltip];//自定义分组堆积柱状图tooltip内容
48-
49-
case 5: return [self configureSpecialStyleTrianglePolarChart];//外部显示六边形边框的三角形雷达图
50-
case 6: return [self customArearangeChartTooltip];//自定义面积范围图的 tooltip
51-
case 7: return [self customLineChartOriginalPointPositionByConfiguringXAxisFormatterAndTooltipFormatter];//通过自定义X轴的 labels 的 Formatter 和 tooltip 的 Formatter 来调整折线图的 X 轴左边距
52-
case 8: return [self customTooltipWhichDataSourceComeFromOutSideRatherThanSeries];//通过来自外部的数据源来自定义 tooltip (而非常规的来自图表的 series)
53-
case 9: return [self customAreasplineChartTooltipStyleByDivWithCSS];//通过自定义 div 的 css 样式来自定义复杂效果的 tooltip 浮动提示框
54-
55-
default:
56-
return nil;
57-
}
58-
}
59-
60-
6141
//https://github.com/AAChartModel/AAChartKit/issues/569
6242
+ (AAOptions *)customAreaChartTooltipStyleWithSimpleFormatString {
6343
AAChartModel *aaChartModel = AAChartModel.new

AAChartKitDemo/Demo/AAOptionsWithJS/Composer/JSFunctionForAATooltipV2Composer.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ NS_ASSUME_NONNULL_BEGIN
66

77
@interface JSFunctionForAATooltipV2Composer : NSObject
88

9-
+ (id)chartConfigurationWithSelectedIndex:(NSUInteger)selectedIndex;
10-
119
+ (AAOptions *)customTooltipPostionerFunction;
1210
+ (AAOptions *)fixedTooltipPositionByCustomPositionerFunction;
1311
+ (AAOptions *)customPlotAreaOutsideComlicatedTooltipStyle;

AAChartKitDemo/Demo/AAOptionsWithJS/Composer/JSFunctionForAATooltipV2Composer.m

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,6 @@ @interface JSFunctionForAATooltipV2Composer ()
1515

1616
@implementation JSFunctionForAATooltipV2Composer
1717

18-
19-
+ (id)chartConfigurationWithSelectedIndex:(NSUInteger)selectedIndex {
20-
switch (selectedIndex) {
21-
case 0: return [self customColumnChartBorderStyleAndStatesHoverColor];//自定义📊柱状图的 border 样式和手指或鼠标 hover 时的显示效果
22-
case 1: return [self customTooltipPostionerFunction];//自定义浮动提示框 Positioner 函数
23-
case 2: return [self fixedTooltipPositionByCustomPositionerFunction];//通过 Positioner 函数来实现一个位置固定的提示框
24-
case 3: return [self customPlotAreaOutsideComlicatedTooltipStyle];//通过 Positioner 函数来实现绘图区外的复杂浮动提示框样式
25-
case 4: return [self makePieChartShow0Data];//使饼图显示为 0 的数据
26-
case 5: return [self customizeTooltipShapeAndShadowBeSpecialStyle];
27-
case 6: return [self specialStyleForAreaChart];//特殊样式的区域图
28-
29-
default:
30-
return nil;
31-
}
32-
}
33-
3418
//https://github.com/AAChartModel/AAChartKit/issues/966
3519
+ (AAOptions *)customTooltipPostionerFunction {
3620
NSArray *categoriesArr = @[
@@ -194,7 +178,7 @@ + (AAOptions *)customPlotAreaOutsideComlicatedTooltipStyle {
194178
.heightSet(@"70%")//https://api.highcharts.com/highcharts/yAxis.height
195179
;
196180

197-
CGFloat screenWidth = self.view.frame.size.width;
181+
CGFloat screenWidth = UIScreen.mainScreen.bounds.size.width;
198182

199183
NSString *positionerStr = [NSString stringWithFormat:@AAJSFunc(function (labelWidth, labelHeight, point) {
200184
const xPosition = point.plotX;

0 commit comments

Comments
 (0)