Skip to content

Commit a4014a1

Browse files
committed
1 parent fb66c6f commit a4014a1

File tree

4 files changed

+301
-1
lines changed

4 files changed

+301
-1
lines changed

AAChartKitDemo.xcodeproj/project.pbxproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@
8686
8463FDE128CB1F5F00392C50 /* JSFunctionForAALegendVC.m in Sources */ = {isa = PBXBuildFile; fileRef = 8463FDE028CB1F5F00392C50 /* JSFunctionForAALegendVC.m */; };
8787
846CB10D26A6B14100DE8D5A /* AAColumnrange.m in Sources */ = {isa = PBXBuildFile; fileRef = 846CB10C26A6B14100DE8D5A /* AAColumnrange.m */; };
8888
8483CEC229D2F40D002E57AA /* AADOMRectModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 8483CEC129D2F40D002E57AA /* AADOMRectModel.m */; };
89+
8486A22A2BAD830600AA343B /* DoubleChartsLinkedWorkVC2.m in Sources */ = {isa = PBXBuildFile; fileRef = 8486A2292BAD830600AA343B /* DoubleChartsLinkedWorkVC2.m */; };
8990
848FEAFC265E170C006E4F25 /* TestAAChartViewForXibVC.m in Sources */ = {isa = PBXBuildFile; fileRef = 848FEAFA265E170C006E4F25 /* TestAAChartViewForXibVC.m */; };
9091
848FEAFD265E170C006E4F25 /* TestAAChartViewForXibVC.xib in Resources */ = {isa = PBXBuildFile; fileRef = 848FEAFB265E170C006E4F25 /* TestAAChartViewForXibVC.xib */; };
9192
84AE6B1C26A1775A001F0755 /* AADateTimeLabelFormats.m in Sources */ = {isa = PBXBuildFile; fileRef = 84AE6B1B26A1775A001F0755 /* AADateTimeLabelFormats.m */; };
@@ -286,6 +287,8 @@
286287
846CB10C26A6B14100DE8D5A /* AAColumnrange.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AAColumnrange.m; sourceTree = "<group>"; };
287288
8483CEC029D2F40D002E57AA /* AADOMRectModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AADOMRectModel.h; sourceTree = "<group>"; };
288289
8483CEC129D2F40D002E57AA /* AADOMRectModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AADOMRectModel.m; sourceTree = "<group>"; };
290+
8486A2282BAD830600AA343B /* DoubleChartsLinkedWorkVC2.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DoubleChartsLinkedWorkVC2.h; sourceTree = "<group>"; };
291+
8486A2292BAD830600AA343B /* DoubleChartsLinkedWorkVC2.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DoubleChartsLinkedWorkVC2.m; sourceTree = "<group>"; };
289292
848FEAF9265E170C006E4F25 /* TestAAChartViewForXibVC.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = TestAAChartViewForXibVC.h; sourceTree = "<group>"; };
290293
848FEAFA265E170C006E4F25 /* TestAAChartViewForXibVC.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = TestAAChartViewForXibVC.m; sourceTree = "<group>"; };
291294
848FEAFB265E170C006E4F25 /* TestAAChartViewForXibVC.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = TestAAChartViewForXibVC.xib; sourceTree = "<group>"; };
@@ -523,6 +526,8 @@
523526
4486C50F23E9BAB300B54849 /* DrawableChartVC.m */,
524527
4486C50B23DE02A900B54849 /* DoubleChartsLinkedWorkVC.h */,
525528
4486C50C23DE02A900B54849 /* DoubleChartsLinkedWorkVC.m */,
529+
8486A2282BAD830600AA343B /* DoubleChartsLinkedWorkVC2.h */,
530+
8486A2292BAD830600AA343B /* DoubleChartsLinkedWorkVC2.m */,
526531
27EB8A8B24986DCE007E6A6B /* DataSortingWithAnimationChartVC.h */,
527532
27EB8A8C24986DCE007E6A6B /* DataSortingWithAnimationChartVC.m */,
528533
84AE6B2026A58D73001F0755 /* AAChartSymbolConstant.h */,
@@ -881,6 +886,7 @@
881886
84E0D36628F2D690004031BE /* JSFunctionForAAOptionsVC.m in Sources */,
882887
44EF0FA524F759FD00F5639A /* AALineStyle.m in Sources */,
883888
44C8C491226F4D4100AB9E50 /* JSFunctionForAATooltipVC.m in Sources */,
889+
8486A22A2BAD830600AA343B /* DoubleChartsLinkedWorkVC2.m in Sources */,
884890
84E0D36F28F2DBBD004031BE /* JSFunctionForAATooltipVC2.m in Sources */,
885891
27EB8A8D24986DCE007E6A6B /* DataSortingWithAnimationChartVC.m in Sources */,
886892
1E66D1FC210AF4ED007EAB8C /* AAAreaspline.m in Sources */,
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
//
2+
// DoubleChartsLinkedWorkVC.h
3+
// AAChartKitDemo
4+
//
5+
// Created by AnAn on 2020/1/27.
6+
// Copyright © 2020 AnAn. All rights reserved.
7+
//*************** ...... SOURCE CODE ...... ***************
8+
//***...................................................***
9+
//*** https://github.com/AAChartModel/AAChartKit ***
10+
//*** https://github.com/AAChartModel/AAChartKit-Swift ***
11+
//***...................................................***
12+
//*************** ...... SOURCE CODE ...... ***************
13+
14+
/*
15+
16+
* -------------------------------------------------------------------------------
17+
*
18+
* 🌕 🌖 🌗 🌘 ❀❀❀ WARM TIPS!!! ❀❀❀ 🌑 🌒 🌓 🌔
19+
*
20+
* Please contact me on GitHub,if there are any problems encountered in use.
21+
* GitHub Issues : https://github.com/AAChartModel/AAChartKit/issues
22+
* -------------------------------------------------------------------------------
23+
* And if you want to contribute for this project, please contact me as well
24+
* GitHub : https://github.com/AAChartModel
25+
* StackOverflow : https://stackoverflow.com/users/12302132/codeforu
26+
* JianShu : https://www.jianshu.com/u/f1e6753d4254
27+
* SegmentFault : https://segmentfault.com/u/huanghunbieguan
28+
*
29+
* -------------------------------------------------------------------------------
30+
31+
*/
32+
33+
#import <UIKit/UIKit.h>
34+
35+
@interface DoubleChartsLinkedWorkVC2 : UIViewController
36+
37+
@end
38+
39+
Lines changed: 250 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,250 @@
1+
//
2+
// DoubleChartsLinkedWorkVC.m
3+
// AAChartKitDemo
4+
//
5+
// Created by AnAn on 2020/1/27.
6+
// Copyright © 2020 AnAn. All rights reserved.
7+
//*************** ...... SOURCE CODE ...... ***************
8+
//***...................................................***
9+
//*** https://github.com/AAChartModel/AAChartKit ***
10+
//*** https://github.com/AAChartModel/AAChartKit-Swift ***
11+
//***...................................................***
12+
//*************** ...... SOURCE CODE ...... ***************
13+
14+
/*
15+
16+
* -------------------------------------------------------------------------------
17+
*
18+
* 🌕 🌖 🌗 🌘 ❀❀❀ WARM TIPS!!! ❀❀❀ 🌑 🌒 🌓 🌔
19+
*
20+
* Please contact me on GitHub,if there are any problems encountered in use.
21+
* GitHub Issues : https://github.com/AAChartModel/AAChartKit/issues
22+
* -------------------------------------------------------------------------------
23+
* And if you want to contribute for this project, please contact me as well
24+
* GitHub : https://github.com/AAChartModel
25+
* StackOverflow : https://stackoverflow.com/users/12302132/codeforu
26+
* JianShu : https://www.jianshu.com/u/f1e6753d4254
27+
* SegmentFault : https://segmentfault.com/u/huanghunbieguan
28+
*
29+
* -------------------------------------------------------------------------------
30+
31+
*/
32+
33+
#import "DoubleChartsLinkedWorkVC2.h"
34+
#import "AAChartKit.h"
35+
@interface DoubleChartsLinkedWorkVC2 ()
36+
37+
@property (nonatomic, strong) AAChartView *aaChartView1;
38+
@property (nonatomic, strong) AAChartView *aaChartView2;
39+
@property (nonatomic, strong) NSArray *gradientColorsArr;
40+
@property (nonatomic, strong) NSDictionary *selectedColor;
41+
42+
43+
@end
44+
45+
@implementation DoubleChartsLinkedWorkVC2
46+
47+
- (void)viewDidLoad {
48+
[super viewDidLoad];
49+
self.title = @"Double Charts Linked Working---双表联动";
50+
self.view.backgroundColor = [UIColor whiteColor];
51+
52+
[self setUpTheAAChartViewOne];
53+
[self setUpTheAAChartViewTwo];
54+
55+
}
56+
57+
//配置第一个 AAChartView
58+
- (void)setUpTheAAChartViewOne {
59+
CGFloat chartViewWidth = self.view.frame.size.width;
60+
CGFloat screenHeight = self.view.frame.size.height;
61+
CGRect frame = CGRectMake(0, 60, chartViewWidth, screenHeight / 2);
62+
AAChartView *aaChartView = [[AAChartView alloc]initWithFrame:frame];
63+
aaChartView.scrollEnabled = NO;
64+
[self.view addSubview:aaChartView];
65+
_aaChartView1 = aaChartView;
66+
[self setupChartViewHandler];
67+
68+
AAChartModel *aaChartModel = AAChartModel.new
69+
.chartTypeSet(AAChartTypeColumn)
70+
.categoriesSet(@[
71+
@"oceanBlue",
72+
@"sanguine",
73+
@"lusciousLime",
74+
@"purpleLake",
75+
@"freshPapaya",
76+
@"ultramarine",
77+
@"pinkSugar",
78+
@"lemonDrizzle",
79+
@"victoriaPurple",
80+
@"springGreens",
81+
@"mysticMauve",
82+
@"reflexSilver",
83+
@"neonGlowColor",
84+
@"berrySmoothieColor",
85+
@"newLeaf",
86+
@"cottonCandy",
87+
@"pixieDust",
88+
@"fizzyPeach",
89+
@"sweetDream",
90+
@"firebrick",
91+
@"wroughtIron",
92+
@"deepSea",
93+
@"coastalBreeze",
94+
@"eveningDelight",
95+
])
96+
.tooltipEnabledSet(false)
97+
.borderRadiusSet(@3)
98+
.legendEnabledSet(false)
99+
.colorsThemeSet(@[
100+
AAGradientColor.oceanBlueColor,
101+
AAGradientColor.sanguineColor,
102+
AAGradientColor.lusciousLimeColor,
103+
AAGradientColor.purpleLakeColor,
104+
AAGradientColor.freshPapayaColor,
105+
AAGradientColor.ultramarineColor,
106+
AAGradientColor.pinkSugarColor,
107+
AAGradientColor.lemonDrizzleColor,
108+
AAGradientColor.victoriaPurpleColor,
109+
AAGradientColor.springGreensColor,
110+
AAGradientColor.mysticMauveColor,
111+
AAGradientColor.reflexSilverColor,
112+
AAGradientColor.neonGlowColor,
113+
AAGradientColor.berrySmoothieColor,
114+
AAGradientColor.newLeafColor,
115+
AAGradientColor.cottonCandyColor,
116+
AAGradientColor.pixieDustColor,
117+
AAGradientColor.fizzyPeachColor,
118+
AAGradientColor.sweetDreamColor,
119+
AAGradientColor.firebrickColor,
120+
AAGradientColor.wroughtIronColor,
121+
AAGradientColor.deepSeaColor,
122+
AAGradientColor.coastalBreezeColor,
123+
AAGradientColor.eveningDelightColor,
124+
])
125+
126+
.seriesSet(@[
127+
AASeriesElement.new
128+
.nameSet(@"ElementOne")
129+
.zIndexSet(@0)
130+
.borderRadiusBottomLeftSet((id)@"50%")
131+
.borderRadiusBottomRightSet((id)@"50%")
132+
.dataSet([self generateRandomNumberArrayWithLength:35.0 randomRange:100 minNum:200])
133+
.colorByPointSet(@true),//When using automatic point colors pulled from the options.colors collection, this option determines whether the chart should receive one color per series or one color per point. Default Value:false.
134+
]);
135+
136+
_gradientColorsArr = aaChartModel.colorsTheme;
137+
138+
AAOptions *aaOptions = aaChartModel.aa_toAAOptions;
139+
aaOptions.plotOptions.column.groupPadding = @0;
140+
aaOptions.yAxis.gridLineWidth = @0;
141+
aaOptions.xAxis
142+
.crosshairSet(AACrosshair.new
143+
.colorSet(AAColor.redColor)
144+
.dashStyleSet(AAChartLineDashStyleTypeLongDashDot)
145+
.zIndexSet(@5)
146+
);
147+
148+
[aaChartView aa_drawChartWithOptions:aaOptions];
149+
}
150+
151+
152+
- (void)setupChartViewHandler {
153+
[_aaChartView1 moveOverEventHandler:^(AAChartView *aaChartView,
154+
AAMoveOverEventMessageModel *message) {
155+
//默认选中的位置索引
156+
NSUInteger defaultSelectedIndex = message.index;
157+
158+
//https://api.highcharts.com/highcharts/chart.events.load
159+
//https://www.highcharts.com/forum/viewtopic.php?t=36508
160+
NSString *jsFunc = ([NSString stringWithFormat:@AAJSFunc((
161+
function syncRefreshTooltip() {
162+
const points = [];
163+
const chart = aaGlobalChart;
164+
const series = chart.series;
165+
const length = series.length;
166+
167+
for (let i = 0; i < length; i++) {
168+
const pointElement = series[i].data[%ld];
169+
pointElement.onMouseOver();
170+
points.push(pointElement);
171+
}
172+
chart.xAxis[0].drawCrosshair(null, points[0]);
173+
chart.tooltip.refresh(points);
174+
}
175+
syncRefreshTooltip();
176+
)), defaultSelectedIndex]);
177+
178+
179+
180+
[self.aaChartView2 aa_evaluateJavaScriptStringFunction:jsFunc];
181+
}];
182+
}
183+
184+
- (NSArray *)generateRandomNumberArrayWithLength:(NSUInteger)length
185+
randomRange:(NSUInteger)randomRange
186+
minNum:(NSUInteger)minNum {
187+
NSMutableArray *randomNumArrA = [NSMutableArray array];
188+
for (NSUInteger x = 0; x < length; x++) {
189+
NSUInteger randomNum = arc4random() % randomRange + minNum;
190+
[randomNumArrA addObject:@(randomNum)];
191+
}
192+
return randomNumArrA;
193+
}
194+
195+
//配置第二个 AAChartView
196+
- (void)setUpTheAAChartViewTwo {
197+
CGFloat chartViewWidth = self.view.frame.size.width;
198+
CGFloat screenHeight = self.view.frame.size.height;
199+
CGRect frame = CGRectMake(0, screenHeight / 2 + 60, chartViewWidth, screenHeight / 2 - 60);
200+
AAChartView *aaChartView2 = [[AAChartView alloc]initWithFrame:frame];
201+
aaChartView2.scrollEnabled = NO;
202+
[self.view addSubview:aaChartView2];
203+
_aaChartView2 = aaChartView2;
204+
205+
AAChartModel *aaChartModel2 = AAChartModel.new
206+
.chartTypeSet(AAChartTypeAreaspline)
207+
.markerSymbolStyleSet(AAChartSymbolStyleTypeBorderBlank)
208+
.markerRadiusSet(@6)
209+
.stackingSet(AAChartStackingTypeNormal)
210+
.xAxisCrosshairSet([AACrosshair crosshairWithColor:AAColor.redColor dashStyle:AAChartLineDashStyleTypeDashDot])
211+
.legendEnabledSet(false)
212+
.seriesSet(@[
213+
AASeriesElement.new
214+
.nameSet(@"2018")
215+
.lineWidthSet(@6)
216+
.dataSet([self generateRandomNumberArrayWithLength:35.0 randomRange:100 minNum:200]),
217+
AASeriesElement.new
218+
.nameSet(@"2019")
219+
.lineWidthSet(@6)
220+
.dataSet([self generateRandomNumberArrayWithLength:35.0 randomRange:150 minNum:400]),
221+
AASeriesElement.new
222+
.nameSet(@"2020")
223+
.lineWidthSet(@6)
224+
.dataSet([self generateRandomNumberArrayWithLength:35.0 randomRange:150 minNum:600]),
225+
AASeriesElement.new
226+
.nameSet(@"2018")
227+
.lineWidthSet(@6)
228+
.dataSet([self generateRandomNumberArrayWithLength:35.0 randomRange:100 minNum:200]),
229+
AASeriesElement.new
230+
.nameSet(@"2019")
231+
.lineWidthSet(@6)
232+
.dataSet([self generateRandomNumberArrayWithLength:35.0 randomRange:150 minNum:400]),
233+
AASeriesElement.new
234+
.nameSet(@"2020")
235+
.lineWidthSet(@6)
236+
.dataSet([self generateRandomNumberArrayWithLength:35.0 randomRange:150 minNum:600]),
237+
]);
238+
239+
AAOptions *aaOptions2 = aaChartModel2.aa_toAAOptions;
240+
aaOptions2.plotOptions.column.groupPadding = @0;
241+
aaOptions2.yAxis.gridLineWidth = @0;
242+
243+
[aaChartView2 aa_drawChartWithOptions:aaOptions2];
244+
245+
}
246+
247+
248+
249+
250+
@end

AAChartKitDemo/ChartsDemo/MainVC.m

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
#import "EvaluateJSStringFunctionVC.h"
4949
#import "ScrollingUpdateDataVC.h"
5050
#import "DoubleChartsLinkedWorkVC.h"
51+
#import "DoubleChartsLinkedWorkVC2.h"
5152
#import "DrawableChartVC.h"
5253
#import "DataSortingWithAnimationChartVC.h"
5354
#import "ChartAdvancedUpdatingFeatureVC.h"
@@ -260,9 +261,12 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
260261
} else if (row == 1) {
261262
ChartListVC *listVC = ChartListVC.new;
262263
[self.navigationController pushViewController:listVC animated:YES];
263-
} else {
264+
} else if (row == 2) {
264265
DoubleChartsLinkedWorkVC *vc = DoubleChartsLinkedWorkVC.new;
265266
[self.navigationController pushViewController:vc animated:YES];
267+
} else if (row == 3) {
268+
DoubleChartsLinkedWorkVC2 *vc = DoubleChartsLinkedWorkVC2.new;
269+
[self.navigationController pushViewController:vc animated:YES];
266270
}
267271
}
268272
break;
@@ -646,6 +650,7 @@ - (NSArray *)chartTypeNameArr {
646650
@[@"Show Two AAChartView On View---同时显示多个 AAChartView",
647651
@"Show Many AAChartView On UITableView---UITableView上显示多个 AAChartView",
648652
@"Double Charts Linked Working---双表联动",
653+
@"Double Charts Linked Working2---双表联动2",
649654
],
650655
/*隐藏或显示图表的Series*/
651656
@[@"Column Chart---柱形图",

0 commit comments

Comments
 (0)