Skip to content

Commit b4a6566

Browse files
committed
Add triple Y Axes mixed sample chart
1 parent f193d96 commit b4a6566

5 files changed

Lines changed: 121 additions & 9 deletions

File tree

AAChartKitDemo/ChartsDemo/DrawChartWithAAOptionsVC.m

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ - (AAOptions *)configureChartOptions {
111111
case 27: return [self configureXAxisPlotBand];//X轴带有颜色标志带的混合图表
112112
case 28: return [self configureStackingColumnChartDataLabelsOverflow];//允许DataLabels文字溢出绘图区
113113
case 29: return [self configureReversedBarChartDataLabelsStyle];//调整Y轴倒转的条形图的DataLabels风格样式
114+
case 30: return [self configureTripleYAxesMixedChart];//三条Y轴的混合图
114115
}
115116
return nil;
116117
}
@@ -1732,5 +1733,113 @@ - (AAOptions *)configureReversedBarChartDataLabelsStyle {
17321733
return aaOptions;
17331734
}
17341735

1736+
- (AAOptions *)configureTripleYAxesMixedChart {
1737+
NSArray *colorsThemeArr = @[@"red",@"mediumspringgreen",@"deepskyblue",];
1738+
1739+
AATitle *aaTitle = AATitle.new
1740+
.textSet(@"东京月平均天气数据");
1741+
1742+
AASubtitle *aaSubtitle = AASubtitle.new
1743+
.textSet(@"数据来源: WorldClimate.com");
1744+
1745+
AAXAxis *aaXAxis = AAXAxis.new
1746+
.visibleSet(true)
1747+
.minSet(@0)
1748+
.categoriesSet(@[@"一月", @"二月", @"三月", @"四月", @"五月", @"六月",
1749+
@"七月", @"八月", @"九月", @"十月", @"十一月", @"十二月"]);
1750+
1751+
AAYAxis *yAxis1 = AAYAxis.new
1752+
.visibleSet(true)
1753+
.gridLineWidthSet(@0)
1754+
.labelsSet(AALabels.new
1755+
.enabledSet(true)//设置 y 轴是否显示数字
1756+
.formatSet(@"{value}°C")
1757+
.styleSet(AAStyle.new
1758+
.colorSet(colorsThemeArr[0])//yAxis Label font color
1759+
))
1760+
.titleSet(AAAxisTitle.new
1761+
.textSet(@"温度")
1762+
.styleSet(AAStyle.new
1763+
.colorSet(colorsThemeArr[0])))
1764+
.oppositeSet(true);
1765+
1766+
1767+
AAYAxis *yAxis2 = AAYAxis.new
1768+
.visibleSet(true)
1769+
.gridLineWidthSet(@0)
1770+
.labelsSet(AALabels.new
1771+
.enabledSet(true)//设置 y 轴是否显示数字
1772+
.formatSet(@"{value}°mm")
1773+
.styleSet(AAStyle.new
1774+
.colorSet(colorsThemeArr[1])//yAxis Label font color
1775+
))
1776+
.titleSet(AAAxisTitle.new
1777+
.textSet(@"降雨量")
1778+
.styleSet(AAStyle.new
1779+
.colorSet(colorsThemeArr[1])));
1780+
1781+
AAYAxis *yAxis3 = AAYAxis.new
1782+
.visibleSet(true)
1783+
.gridLineWidthSet(@0)
1784+
.labelsSet(AALabels.new
1785+
.enabledSet(true)//设置 y 轴是否显示数字
1786+
.formatSet(@"{value}°mb")
1787+
.styleSet(AAStyle.new
1788+
.colorSet(colorsThemeArr[2])//yAxis Label font color
1789+
))
1790+
.titleSet(AAAxisTitle.new
1791+
.textSet(@"海平面气压")
1792+
.styleSet(AAStyle.new
1793+
.colorSet(colorsThemeArr[2])));
1794+
1795+
AATooltip *aaTooltip = AATooltip.new
1796+
.enabledSet(true)
1797+
.sharedSet(true);
1798+
1799+
AALegend *aaLegend = AALegend.new
1800+
.layoutSet(AAChartLayoutTypeVertical)
1801+
.alignSet(AAChartAlignTypeLeft)
1802+
.xSet(@80)
1803+
.verticalAlignSet(AAChartVerticalAlignTypeTop)
1804+
.ySet(@55);
1805+
1806+
AASeriesElement *element1 = AASeriesElement.new
1807+
.nameSet(@"降雨量")
1808+
.typeSet(AAChartTypeColumn)
1809+
.yAxisSet(@1)
1810+
.dataSet(@[@49.9, @71.5, @106.4, @129.2, @144.0, @176.0, @135.6, @148.5, @216.4, @194.1, @95.6, @54.4])
1811+
.tooltipSet(AATooltip.new
1812+
.valueSuffixSet(@" mm"));
1813+
1814+
AASeriesElement *element2 = AASeriesElement.new
1815+
.nameSet(@"海平面气压")
1816+
.typeSet(AAChartTypeSpline)
1817+
.yAxisSet(@2)
1818+
.dataSet(@[@1016, @1016, @1015.9, @1015.5, @1012.3, @1009.5, @1009.6, @1010.2, @1013.1, @1016.9, @1018.2, @1016.7])
1819+
.dashStyleSet(AAChartLineDashStyleTypeShortDot)
1820+
.tooltipSet(AATooltip.new
1821+
.valueSuffixSet(@" mb"));
1822+
1823+
AASeriesElement *element3 = AASeriesElement.new
1824+
.nameSet(@"温度")
1825+
.typeSet(AAChartTypeSpline)
1826+
.yAxisSet(@0)
1827+
.dataSet(@[@7.0, @6.9, @9.5, @14.5, @18.2, @21.5, @25.2, @26.5, @23.3, @18.3, @13.9, @9.6])
1828+
.tooltipSet(AATooltip.new
1829+
.valueSuffixSet(@""));
1830+
1831+
AAOptions *aaOptions = AAOptions.new
1832+
.titleSet(aaTitle)
1833+
.subtitleSet(aaSubtitle)
1834+
.colorsSet(colorsThemeArr)
1835+
.xAxisSet(aaXAxis)
1836+
.yAxisSet((id)@[yAxis1,yAxis2,yAxis3])
1837+
.tooltipSet(aaTooltip)
1838+
.legendSet(aaLegend)
1839+
.seriesSet(@[element1,element2,element3])
1840+
;
1841+
return aaOptions;
1842+
}
1843+
17351844

17361845
@end

AAChartKitDemo/ChartsDemo/FirstViewController.m

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,8 @@ - (NSArray *)chartTypeNameArr {
384384
@"配置DataLabels、XAXis、YAxis、Legend等图表元素样式",
385385
@"X轴带有颜色标志带的混合图表",
386386
@"允许DataLabels文字溢出绘图区",
387-
@"调整Y轴倒转的条形图的DataLabels风格样式"
387+
@"调整Y轴倒转的条形图的DataLabels风格样式",
388+
@"Triple Y Axes Mixed Chart---三条 Y 轴的混合图"
388389
],
389390
/*同时显示多个 AAChartView*/
390391
@[@"同时显示多个 AAChartView",

AAChartKitLib/AAChartConfiger/AAChartView.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -190,13 +190,13 @@ typedef void(^AAMoveOverEventBlock)(AAChartView *aaChartView, AAMoveOverEventMes
190190
///Same as the function `func aa_addPointToChartSeriesElement(elementIndex: Int, options: Any, redraw: Bool, shift: Bool, animation: Bool)`
191191
///
192192
- (void)aa_addPointToChartSeriesElementWithElementIndex:(NSUInteger)elementIndex
193-
options:(NSObject *)options;
193+
options:(NSObject *)options;
194194

195195
///Same as the function `func aa_addPointToChartSeriesElement(elementIndex: Int, options: Any, redraw: Bool, shift: Bool, animation: Bool)`
196196
///
197197
- (void)aa_addPointToChartSeriesElementWithElementIndex:(NSUInteger)elementIndex
198-
options:(NSObject *)options
199-
shift:(BOOL)shift;
198+
options:(NSObject *)options
199+
shift:(BOOL)shift;
200200

201201
/// Add a new point to the data column after the chart has been rendered.
202202
/// The new point can be the last point, or it can be placed in the corresponding position given the X value (first, middle position, depending on the x value)
@@ -208,10 +208,10 @@ typedef void(^AAMoveOverEventBlock)(AAChartView *aaChartView, AAMoveOverEventMes
208208
/// @Parameter shift: The default is false. When this property is true, adding a new point will delete the first point in the data column (that is, keep the total number of data points in the data column unchanged). This property is very useful in the inspection chart
209209
/// @Parameter animation: The default is true, which means that when adding a point, it contains the default animation effect. This parameter can also be passed to the object form containing duration and easing. For details, refer to the animation related configuration.
210210
- (void)aa_addPointToChartSeriesElementWithElementIndex:(NSUInteger)elementIndex
211-
options:(NSObject *)options
212-
redraw:(BOOL)redraw
213-
shift:(BOOL)shift
214-
animation:(BOOL)animation;
211+
options:(NSObject *)options
212+
redraw:(BOOL)redraw
213+
shift:(BOOL)shift
214+
animation:(BOOL)animation;
215215

216216
/// Add a new series element to the chart after the chart has been rendered.
217217
/// Refer to https://api.highcharts.com.cn/highcharts#Chart.addSeries

AAChartKitLib/AAChartConfiger/AASeriesElement.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232

3333
#import <Foundation/Foundation.h>
3434

35-
@class AAMarker,AADataLabels;
35+
@class AAMarker,AADataLabels,AATooltip;
3636

3737
@interface AASeriesElement : NSObject
3838

@@ -66,6 +66,7 @@ AAPropStatementAndPropSetFuncStatement(strong, AASeriesElement, NSArray *, zone
6666
AAPropStatementAndPropSetFuncStatement(copy, AASeriesElement, NSString *, zoneAxis)
6767
AAPropStatementAndPropSetFuncStatement(strong, AASeriesElement, id, shadow) //数据列的阴影效果。从 2.3 开始阴影可以配置成包含 color、offsetX、offsetY、opacity 和 width 属性的对象形式。 默认是:false
6868
AAPropStatementAndPropSetFuncStatement(copy, AASeriesElement, NSString *, stack)
69+
AAPropStatementAndPropSetFuncStatement(strong, AASeriesElement, AATooltip*, tooltip)
6970

7071

7172

AAChartKitLib/AAChartConfiger/AASeriesElement.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ - (instancetype)init {
7575
AAPropSetFuncImplementation(AASeriesElement, NSString *, zoneAxis)
7676
AAPropSetFuncImplementation(AASeriesElement, id, shadow) //数据列的阴影效果。从 2.3 开始阴影可以配置成包含 color、offsetX、offsetY、opacity 和 width 属性的对象形式。 默认是:false
7777
AAPropSetFuncImplementation(AASeriesElement, NSString *, stack)
78+
AAPropSetFuncImplementation(AASeriesElement, AATooltip*, tooltip)
7879

7980

8081

0 commit comments

Comments
 (0)