diff --git a/AAChartKitDemo/ChartsDemo/JSFunctionForAAChartEventsComposer2.h b/AAChartKitDemo/ChartsDemo/JSFunctionForAAChartEventsComposer2.h index 64d11c618..8d570621c 100644 --- a/AAChartKitDemo/ChartsDemo/JSFunctionForAAChartEventsComposer2.h +++ b/AAChartKitDemo/ChartsDemo/JSFunctionForAAChartEventsComposer2.h @@ -8,10 +8,14 @@ #import +@class AAOptions; + NS_ASSUME_NONNULL_BEGIN @interface JSFunctionForAAChartEventsComposer2 : NSObject ++ (AAOptions *)defaultSelectedAPointForLineChart; + @end NS_ASSUME_NONNULL_END diff --git a/AAChartKitDemo/ChartsDemo/JSFunctionForAAChartEventsComposer2.m b/AAChartKitDemo/ChartsDemo/JSFunctionForAAChartEventsComposer2.m index 2ec0cf389..fdc507694 100644 --- a/AAChartKitDemo/ChartsDemo/JSFunctionForAAChartEventsComposer2.m +++ b/AAChartKitDemo/ChartsDemo/JSFunctionForAAChartEventsComposer2.m @@ -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 diff --git a/AAChartKitDemo/ChartsDemo/JSFunctionForAAChartEventsVC.m b/AAChartKitDemo/ChartsDemo/JSFunctionForAAChartEventsVC.m index 10b262b7b..5c8381848 100644 --- a/AAChartKitDemo/ChartsDemo/JSFunctionForAAChartEventsVC.m +++ b/AAChartKitDemo/ChartsDemo/JSFunctionForAAChartEventsVC.m @@ -35,6 +35,7 @@ #import "JSFunctionForAAChartEventsVC.h" #import "AAChartKit.h" #import "AADateUTCTool.h" +#import "JSFunctionForAAChartEventsComposer2.h" @interface JSFunctionForAAChartEventsVC () @@ -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; diff --git a/AAChartKitLib/AAChartCreator/AASeriesElement.h b/AAChartKitLib/AAChartCreator/AASeriesElement.h index 91ddd03a9..4eacf2c7d 100755 --- a/AAChartKitLib/AAChartCreator/AASeriesElement.h +++ b/AAChartKitLib/AAChartCreator/AASeriesElement.h @@ -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 diff --git a/AAChartKitLib/AAChartCreator/AASeriesElement.m b/AAChartKitLib/AAChartCreator/AASeriesElement.m index d90a14b49..0b6ca0c48 100755 --- a/AAChartKitLib/AAChartCreator/AASeriesElement.m +++ b/AAChartKitLib/AAChartCreator/AASeriesElement.m @@ -102,6 +102,7 @@ @implementation AADataElement AAPropSetFuncImplementation(AADataElement, NSString *, name) AAPropSetFuncImplementation(AADataElement, NSNumber *, x) AAPropSetFuncImplementation(AADataElement, NSNumber *, y) +AAPropSetFuncImplementation(AADataElement, id, selected) @end diff --git a/AAChartKitLib/AAOptionsModel/AAMarker.h b/AAChartKitLib/AAOptionsModel/AAMarker.h index 5638cbeec..92d9c38fa 100755 --- a/AAChartKitLib/AAOptionsModel/AAMarker.h +++ b/AAChartKitLib/AAOptionsModel/AAMarker.h @@ -34,7 +34,7 @@ #import -@class AAMarkerStates, AAMarkerHover; +@class AAMarkerStates, AAMarkerHover, AAMarkerSelect; @interface AAMarker : NSObject @@ -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 @@ -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 diff --git a/AAChartKitLib/AAOptionsModel/AAMarker.m b/AAChartKitLib/AAOptionsModel/AAMarker.m index df66014c3..3699e2c24 100755 --- a/AAChartKitLib/AAOptionsModel/AAMarker.m +++ b/AAChartKitLib/AAOptionsModel/AAMarker.m @@ -59,7 +59,8 @@ - (instancetype)init { @implementation AAMarkerStates -AAPropSetFuncImplementation(AAMarkerStates, AAMarkerHover *, hover) +AAPropSetFuncImplementation(AAMarkerStates, AAMarkerHover *, hover) +AAPropSetFuncImplementation(AAMarkerStates, AAMarkerSelect *, select) @end @@ -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 + + diff --git a/AAChartKitLib/AAOptionsModel/AASeries.h b/AAChartKitLib/AAOptionsModel/AASeries.h index 94b1fdcc9..6a850dd3a 100755 --- a/AAChartKitLib/AAOptionsModel/AASeries.h +++ b/AAChartKitLib/AAOptionsModel/AASeries.h @@ -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) //柱状图, 条形图, 柱形范围图, 瀑布图, 箱线图(盒须图)直接设置单个图形元素的最大宽度 @@ -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 diff --git a/AAChartKitLib/AAOptionsModel/AASeries.m b/AAChartKitLib/AAOptionsModel/AASeries.m index ec66ff7d6..6e193d37b 100755 --- a/AAChartKitLib/AAOptionsModel/AASeries.m +++ b/AAChartKitLib/AAOptionsModel/AASeries.m @@ -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) //柱状图, 条形图, 柱形范围图, 瀑布图, 箱线图(盒须图)直接设置单个图形元素的最大宽度 @@ -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