Skip to content

Commit

Permalink
Fix #1532
Browse files Browse the repository at this point in the history
  • Loading branch information
AAChartModel committed Jan 29, 2024
1 parent 907b3a6 commit 122a8a9
Show file tree
Hide file tree
Showing 9 changed files with 110 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,14 @@

#import <Foundation/Foundation.h>

@class AAOptions;

NS_ASSUME_NONNULL_BEGIN

@interface JSFunctionForAAChartEventsComposer2 : NSObject

+ (AAOptions *)defaultSelectedAPointForLineChart;

@end

NS_ASSUME_NONNULL_END
79 changes: 43 additions & 36 deletions AAChartKitDemo/ChartsDemo/JSFunctionForAAChartEventsComposer2.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,43 +8,50 @@

#import "JSFunctionForAAChartEventsComposer2.h"
#import "AAChartKit.h"
#import "AAOptions.h"

@implementation JSFunctionForAAChartEventsComposer2
//+ (AAOptions *)defaultSelectedAPointForLineChart {
// AADataElement *defaultPointData = AADataElement.new.ySet(@29.9).selectedSet(true);
//
// NSArray *dataArr = @[@29.9, @71.5, @106.4, @129.2, @144.0, @176.0, @135.6, @148.5, @216.4, @194.1, @95.6, defaultPointData];
// NSInteger defaultPointIndex = dataArr.count - 1;
//
// AAOptions *options = AAOptions.new
// .xAxisSet(AAXAxis.new
// .categoriesSet(@[@"Jan", @"Feb", @"Mar", @"Apr", @"May", @"Jun", @"Jul", @"Aug", @"Sep", @"Oct", @"Nov", @"Dec"]))
// .plotOptionsSet(AAPlotOptions.new
// .seriesSet(AASeries.new
// .eventsSet(AASeriesEvents.new
// .mouseOverSet([NSString stringWithFormat:@"function () {\
// if(this.hasRun) return;\
// \
// var series = this;\
// var defaultPointIndex = %ld;\
// if (series.data.length > defaultPointIndex) {\
// defaultPoint = series.data[defaultPointIndex];\
// defaultPoint.select(false);\
// }\
// \
// this.hasRun = true;\
// }", (long)defaultPointIndex])
// .allowPointSelectSet(true)
// .markerSet(AAMarker.new
// .statesSet(AAMarkerStates.new
// .selectSet(AAMarkerSelect.new
// .fillColorSet(@"red")
// .lineWidthSet(@10)
// .lineColorSet(@"yellow")
// .radiusSet(@20)))))))
// .seriesSet(@[AASeriesElement.new.dataSet(dataArr)]);
//
// return options;
//}

+ (AAOptions *)defaultSelectedAPointForLineChart {
AADataElement *defaultPointData = AADataElement.new
.ySet(@29.9)
.selectedSet(@true);

NSArray *dataArr = @[@29.9, @71.5, @106.4, @129.2, @144.0, @176.0, @135.6, @148.5, @216.4, @194.1, @95.6, defaultPointData];
NSInteger defaultPointIndex = dataArr.count - 1;

AAOptions *options = AAOptions.new
.xAxisSet(AAXAxis.new
.categoriesSet(@[@"Jan", @"Feb", @"Mar", @"Apr", @"May", @"Jun", @"Jul", @"Aug", @"Sep", @"Oct", @"Nov", @"Dec"]))
.plotOptionsSet(AAPlotOptions.new
.seriesSet(AASeries.new
.eventsSet(AASeriesEvents.new
.mouseOverSet([NSString stringWithFormat:@AAJSFunc(function () {
if(this.hasRun) return;

var series = this;
var defaultPointIndex = %ld;
if (series.data.length > defaultPointIndex) {
defaultPoint = series.data[defaultPointIndex];
defaultPoint.select(false);
}

this.hasRun = true;
}), (long)defaultPointIndex]))
.allowPointSelectSet(@true)
.markerSet(AAMarker.new
.statesSet(AAMarkerStates.new
.selectSet(AAMarkerSelect.new
.fillColorSet(@"red")
.lineWidthSet(@10)
.lineColorSet(@"yellow")
.radiusSet(@20))))))
.seriesSet(@[
AASeriesElement.new
.dataSet(dataArr)
]);

return options;
}

@end
5 changes: 4 additions & 1 deletion AAChartKitDemo/ChartsDemo/JSFunctionForAAChartEventsVC.m
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#import "JSFunctionForAAChartEventsVC.h"
#import "AAChartKit.h"
#import "AADateUTCTool.h"
#import "JSFunctionForAAChartEventsComposer2.h"

@interface JSFunctionForAAChartEventsVC ()

Expand All @@ -60,7 +61,9 @@ - (id)chartConfigurationWithSelectedIndex:(NSUInteger)selectedIndex {
case 8: return [self customizeYAxisPlotLinesLabelBeSpecialStyle]; //自定义 Y 轴轴线上面的标签文字特殊样式
case 9: return [self configureECGStyleChart]; //配置心电图样式的图表
case 10: return [self configureTheSizeOfTheSliceOfDonutAndPieChart]; //配置环形图和饼图的扇区大小
case 11: return [self configurePlotBackgroundClickEvent]; //配置绘图区的点击事件
// case 11: return [self configurePlotBackgroundClickEvent]; //配置绘图区的点击事件
case 11: return [JSFunctionForAAChartEventsComposer2 defaultSelectedAPointForLineChart];


}
return nil;
Expand Down
1 change: 1 addition & 0 deletions AAChartKitLib/AAChartCreator/AASeriesElement.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ AAPropStatementAndPropSetFuncStatement(strong, AADataElement, AAMarker *, marker
AAPropStatementAndPropSetFuncStatement(copy , AADataElement, NSString *, name)
AAPropStatementAndPropSetFuncStatement(strong, AADataElement, NSNumber *, x)
AAPropStatementAndPropSetFuncStatement(strong, AADataElement, NSNumber *, y)
AAPropStatementAndPropSetFuncStatement(strong, AADataElement, id, selected)

@end

Expand Down
1 change: 1 addition & 0 deletions AAChartKitLib/AAChartCreator/AASeriesElement.m
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ @implementation AADataElement
AAPropSetFuncImplementation(AADataElement, NSString *, name)
AAPropSetFuncImplementation(AADataElement, NSNumber *, x)
AAPropSetFuncImplementation(AADataElement, NSNumber *, y)
AAPropSetFuncImplementation(AADataElement, id, selected)

@end

Expand Down
13 changes: 11 additions & 2 deletions AAChartKitLib/AAOptionsModel/AAMarker.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

#import <Foundation/Foundation.h>

@class AAMarkerStates, AAMarkerHover;
@class AAMarkerStates, AAMarkerHover, AAMarkerSelect;

@interface AAMarker : NSObject

Expand All @@ -53,7 +53,8 @@ AAPropStatementAndPropSetFuncStatement(strong, AAMarker, NSNumber *, height)

@interface AAMarkerStates : NSObject

AAPropStatementAndPropSetFuncStatement(strong, AAMarkerStates, AAMarkerHover *, hover)
AAPropStatementAndPropSetFuncStatement(strong, AAMarkerStates, AAMarkerHover *, hover)
AAPropStatementAndPropSetFuncStatement(strong, AAMarkerStates, AAMarkerSelect *, select)

@end

Expand All @@ -71,7 +72,15 @@ AAPropStatementAndPropSetFuncStatement(strong, AAMarkerHover, NSNumber *, radius
@end


@interface AAMarkerSelect : NSObject

AAPropStatementAndPropSetFuncStatement(assign, AAMarkerSelect, BOOL, enabled)
AAPropStatementAndPropSetFuncStatement(copy, AAMarkerSelect, NSString *, fillColor)
AAPropStatementAndPropSetFuncStatement(copy, AAMarkerSelect, NSString *, lineColor)
AAPropStatementAndPropSetFuncStatement(strong, AAMarkerSelect, NSNumber *, lineWidth)
AAPropStatementAndPropSetFuncStatement(strong, AAMarkerSelect, NSNumber *, radius)

@end



22 changes: 21 additions & 1 deletion AAChartKitLib/AAOptionsModel/AAMarker.m
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ - (instancetype)init {

@implementation AAMarkerStates

AAPropSetFuncImplementation(AAMarkerStates, AAMarkerHover *, hover)
AAPropSetFuncImplementation(AAMarkerStates, AAMarkerHover *, hover)
AAPropSetFuncImplementation(AAMarkerStates, AAMarkerSelect *, select)

@end

Expand All @@ -84,6 +85,25 @@ - (instancetype)init {
@end


@implementation AAMarkerSelect

- (instancetype)init {
self = [super init];
if (self) {
_enabled = true;
}
return self;
}

AAPropSetFuncImplementation(AAMarkerSelect, BOOL, enabled)
AAPropSetFuncImplementation(AAMarkerSelect, NSString *, fillColor)
AAPropSetFuncImplementation(AAMarkerSelect, NSString *, lineColor)
AAPropSetFuncImplementation(AAMarkerSelect, NSNumber *, lineWidth)
AAPropSetFuncImplementation(AAMarkerSelect, NSNumber *, radius)

@end





Expand Down
4 changes: 4 additions & 0 deletions AAChartKitLib/AAOptionsModel/AASeries.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ AAPropStatementAndPropSetFuncStatement(strong, AASeries, AASeriesEvents *, event
AAPropStatementAndPropSetFuncStatement(strong, AASeries, AAShadow *, shadow)
AAPropStatementAndPropSetFuncStatement(strong, AASeries, AADataLabels *, dataLabels)
AAPropStatementAndPropSetFuncStatement(strong, AASeries, AAStates *, states)
AAPropStatementAndPropSetFuncStatement(strong, AASeries, id , allowPointSelect) //折线图的曲线宽度,默认是:0
AAPropStatementAndPropSetFuncStatement(strong, AASeries, AAPoint *, point)
AAPropStatementAndPropSetFuncStatement(strong, AASeries, NSNumber *, pointWidth) //柱状图, 条形图, 柱形范围图, 瀑布图, 箱线图(盒须图)直接设置单个图形元素的宽度
AAPropStatementAndPropSetFuncStatement(strong, AASeries, NSNumber *, maxPointWidth) //柱状图, 条形图, 柱形范围图, 瀑布图, 箱线图(盒须图)直接设置单个图形元素的最大宽度
Expand All @@ -68,6 +69,9 @@ AAPropStatementAndPropSetFuncStatement(strong, AASeries, NSNumber *, minPointLen

@interface AASeriesEvents : NSObject

AAPropStatementAndPropSetFuncStatement(copy, AASeriesEvents, NSString *, click)
AAPropStatementAndPropSetFuncStatement(copy, AASeriesEvents, NSString *, mouseOver)
AAPropStatementAndPropSetFuncStatement(copy, AASeriesEvents, NSString *, mouseOut)
AAPropStatementAndPropSetFuncStatement(copy, AASeriesEvents, NSString *, legendItemClick)

@end
Expand Down
21 changes: 21 additions & 0 deletions AAChartKitLib/AAOptionsModel/AASeries.m
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ @implementation AASeries
AAPropSetFuncImplementation(AASeries, AAShadow *, shadow)
AAPropSetFuncImplementation(AASeries, AADataLabels *, dataLabels)
AAPropSetFuncImplementation(AASeries, AAStates *, states)
AAPropSetFuncImplementation(AASeries, id , allowPointSelect) //折线图的曲线宽度,默认是:0
AAPropSetFuncImplementation(AASeries, AAPoint *, point)
AAPropSetFuncImplementation(AASeries, NSNumber *, pointWidth) //柱状图, 条形图, 柱形范围图, 瀑布图, 箱线图(盒须图)直接设置单个图形元素的宽度
AAPropSetFuncImplementation(AASeries, NSNumber *, maxPointWidth) //柱状图, 条形图, 柱形范围图, 瀑布图, 箱线图(盒须图)直接设置单个图形元素的最大宽度
Expand All @@ -63,14 +64,34 @@ @implementation AASeries

@implementation AASeriesEvents

//AAPropSetFuncImplementation(AASeriesEvents, NSString *, click)
//AAPropSetFuncImplementation(AASeriesEvents, NSString *, mouseOver)
//AAPropSetFuncImplementation(AASeriesEvents, NSString *, mouseOut)
//AAPropSetFuncImplementation(AAEvents, NSString *, legendItemClick)

AAJSFuncTypePropSetFuncImplementation(AASeriesEvents, NSString *, click)
AAJSFuncTypePropSetFuncImplementation(AASeriesEvents, NSString *, mouseOver)
AAJSFuncTypePropSetFuncImplementation(AASeriesEvents, NSString *, mouseOut)
AAJSFuncTypePropSetFuncImplementation(AASeriesEvents, NSString *, legendItemClick)


- (void)setClick:(NSString *)click {
_click = [click aa_toPureJSString];
}

- (void)setMouseOver:(NSString *)mouseOver {
_mouseOver = [mouseOver aa_toPureJSString];
}

- (void)setMouseOut:(NSString *)mouseOut {
_mouseOut = [mouseOut aa_toPureJSString];
}

- (void)setLegendItemClick:(NSString *)legendItemClick {
_legendItemClick = [legendItemClick aa_toPureJSString];
}


@end


Expand Down

0 comments on commit 122a8a9

Please sign in to comment.