@@ -65,6 +65,8 @@ class DrawChartWithAAOptionsVC: UIViewController {
6565 case 14 : return configureXAxisLabelsFontColorAndFontSizeWithHTMLString ( )
6666 case 15 : return configure_DataLabels_XAXis_YAxis_Legend_Style ( )
6767 case 16 : return configureXAxisPlotBand ( )
68+ case 17 : return configureDoubleYAxisChartOptions ( )
69+ case 18 : return configureTripleYAxesMixedChart ( )
6870 default :
6971 return AAOptions ( )
7072 }
@@ -701,7 +703,7 @@ function () {
701703 . data ( [ 7.0 , 6.9 , 2.5 , 14.5 , 18.2 , 21.5 , 5.2 , 26.5 , 23.3 , 45.3 , 13.9 , 9.6 ] )
702704 ,
703705 ]
704- ) ;
706+ )
705707
706708 let aaOptions = AAOptionsConstructor . configureChartOptions ( aaChartModel)
707709 aaOptions. xAxis? . labels? . useHTML ( true )
@@ -873,6 +875,208 @@ function () {
873875
874876 return aaOptions
875877 }
878+
879+ private func configureDoubleYAxisChartOptions( ) -> AAOptions {
880+ let aaTitle = AATitle ( )
881+ . text ( " " )
882+
883+ let aaXAxis = AAXAxis ( )
884+ . visible ( true )
885+ . min ( 0 )
886+ . categories ( [
887+ " Java " , " Swift " , " Python " , " Ruby " , " PHP " , " Go " , " C " ,
888+ " C# " , " C++ " , " Perl " , " R " , " MATLAB " , " SQL " ] )
889+
890+ let aaYAxisTitleStyle = AAStyle ( )
891+ . color ( " #1e90ff " ) //Title font color
892+ . fontSize ( 14 ) //Title font size
893+ . fontWeight ( . bold) //Title font weight
894+ . textOutline ( " 0px 0px contrast " )
895+
896+ let aaYAxisLabels = AALabels ( )
897+ . enabled ( true ) //设置 y 轴是否显示数字
898+ . format ( " {value:.,0f}mm " ) //让y轴的值完整显示 而不是100000显示为100k,同时单位后缀为°C
899+ . style ( AAStyle ( )
900+ . color ( " #ff0000 " ) //yAxis Label font color
901+ . fontSize ( 15 ) //yAxis Label font size
902+ . fontWeight ( . bold) //yAxis Label font weight
903+ )
904+
905+ let yAxisOne = AAYAxis ( )
906+ . visible ( true )
907+ . labels ( aaYAxisLabels)
908+ . title ( AATitle ( )
909+ . text ( " 冬季降雨量 " )
910+ . style ( aaYAxisTitleStyle) )
911+ . opposite ( true )
912+
913+
914+ let yAxisTwo = AAYAxis ( )
915+ . visible ( true )
916+ . labels ( aaYAxisLabels)
917+ . title ( AATitle ( )
918+ . text ( " 夏季降雨量 " )
919+ . style ( aaYAxisTitleStyle) )
920+
921+ let aaTooltip = AATooltip ( )
922+ . enabled ( true )
923+ . shared ( true )
924+
925+ let gradientColorDic1 = AAGradientColor . linearGradient (
926+ direction: . toTop,
927+ startColor: " #f54ea2 " ,
928+ endColor: " #ff7676 " //颜色字符串设置支持十六进制类型和 rgba 类型
929+ )
930+
931+ let gradientColorDic2 = AAGradientColor . linearGradient (
932+ direction: . toTop,
933+ startColor: " #17ead9 " ,
934+ endColor: " #6078ea " //颜色字符串设置支持十六进制类型和 rgba 类型
935+ )
936+
937+ let aaMarker = AAMarker ( )
938+ . radius ( 7 ) //曲线连接点半径,默认是4
939+ . symbol ( AAChartSymbolType . circle. rawValue) //曲线点类型:"circle", "square", "diamond", "triangle","triangle-down",默认是"circle"
940+ . fillColor ( " #ffffff " ) //点的填充色(用来设置折线连接点的填充色)
941+ . lineWidth ( 3 ) //外沿线的宽度(用来设置折线连接点的轮廓描边的宽度)
942+ . lineColor ( " " ) //外沿线的颜色(用来设置折线连接点的轮廓描边颜色,当值为空字符串时,默认取数据点或数据列的颜色)
943+
944+ let element1 = AASeriesElement ( )
945+ . name ( " 2017 " )
946+ . type ( . areaspline)
947+ // .borderRadius(4)
948+ . color ( gradientColorDic1)
949+ . marker ( aaMarker)
950+ . yAxis ( 1 )
951+ . data ( [ 7.0 , 6.9 , 2.5 , 14.5 , 18.2 , 21.5 , 5.2 , 26.5 , 23.3 , 45.3 , 13.9 , 9.6 ] )
952+
953+ let element2 = AASeriesElement ( )
954+ . name ( " 2018 " )
955+ . type ( . column)
956+ . color ( gradientColorDic2)
957+ . yAxis ( 0 )
958+ . data ( [ 7.0 , 6.9 , 2.5 , 14.5 , 18.2 , 21.5 , 5.2 , 26.5 , 23.3 , 45.3 , 13.9 , 9.6 ] )
959+
960+ let aaOptions = AAOptions ( )
961+ . title ( aaTitle)
962+ . xAxis ( aaXAxis)
963+ . yAxisArray ( [ yAxisOne, yAxisTwo] )
964+ . tooltip ( aaTooltip)
965+ . series ( [ element1, element2] )
966+
967+ return aaOptions
968+ }
969+
970+ private func configureTripleYAxesMixedChart( ) -> AAOptions {
971+ let colorsThemeArr = [ " red " , " mediumspringgreen " , " deepskyblue " , ]
972+
973+ let aaTitle = AATitle ( )
974+ . text ( " 东京月平均天气数据 " )
975+
976+ let aaSubtitle = AASubtitle ( )
977+ . text ( " 数据来源: WorldClimate.com " )
978+
979+ let aaXAxis = AAXAxis ( )
980+ . visible ( true )
981+ . min ( 0 )
982+ . categories ( [ " 一月 " , " 二月 " , " 三月 " , " 四月 " , " 五月 " , " 六月 " ,
983+ " 七月 " , " 八月 " , " 九月 " , " 十月 " , " 十一月 " , " 十二月 " ] )
984+
985+ let yAxis1 = AAYAxis ( )
986+ . visible ( true )
987+ . gridLineWidth ( 0 )
988+ . labels ( AALabels ( )
989+ . enabled ( true ) //设置 y 轴是否显示数字
990+ . format ( " {value}°C " )
991+ . style ( AAStyle ( )
992+ . color ( colorsThemeArr [ 0 ] ) //yAxis Label font color
993+ ) )
994+ . title ( AATitle ( )
995+ . text ( " 温度 " )
996+ . style ( AAStyle ( )
997+ . color ( colorsThemeArr [ 0 ] ) ) )
998+ . opposite ( true )
999+
1000+
1001+ let yAxis2 = AAYAxis ( )
1002+ . visible ( true )
1003+ . gridLineWidth ( 0 )
1004+ . labels ( AALabels ( )
1005+ . enabled ( true ) //设置 y 轴是否显示数字
1006+ . format ( " {value}°mm " )
1007+ . style ( AAStyle ( )
1008+ . color ( colorsThemeArr [ 1 ] ) //yAxis Label font color
1009+ ) )
1010+ . title ( AATitle ( )
1011+ . text ( " 降雨量 " )
1012+ . style ( AAStyle ( )
1013+ . color ( colorsThemeArr [ 1 ] ) ) )
1014+
1015+ let yAxis3 = AAYAxis ( )
1016+ . visible ( true )
1017+ . gridLineWidth ( 0 )
1018+ . labels ( AALabels ( )
1019+ . enabled ( true ) //设置 y 轴是否显示数字
1020+ . format ( " {value}°mb " )
1021+ . style ( AAStyle ( )
1022+ . color ( colorsThemeArr [ 2 ] ) //yAxis Label font color
1023+ ) )
1024+ . title ( AATitle ( )
1025+ . text ( " 海平面气压 " )
1026+ . style ( AAStyle ( )
1027+ . color ( colorsThemeArr [ 2 ] ) ) )
1028+
1029+ let aaTooltip = AATooltip ( )
1030+ . enabled ( true )
1031+ . shared ( true )
1032+
1033+ let aaLegend = AALegend ( )
1034+ . enabled ( true )
1035+ . layout ( . vertical)
1036+ . align ( . center)
1037+ . x ( 80 )
1038+ . verticalAlign ( . top)
1039+ . y ( 55 )
1040+
1041+ let element1 = AASeriesElement ( )
1042+ . name ( " 降雨量 " )
1043+ . type ( . column)
1044+ . yAxis ( 1 )
1045+ . data ( [ 49.9 , 71.5 , 106.4 , 129.2 , 144.0 , 176.0 , 135.6 , 148.5 , 216.4 , 194.1 , 95.6 , 54.4 ] )
1046+ . tooltip ( AATooltip ( )
1047+ . valueSuffix ( " mm " ) )
1048+
1049+ let element2 = AASeriesElement ( )
1050+ . name ( " 海平面气压 " )
1051+ . type ( . spline)
1052+ . yAxis ( 2 )
1053+ . data ( [ 1016 , 1016 , 1015.9 , 1015.5 , 1012.3 , 1009.5 , 1009.6 , 1010.2 , 1013.1 , 1016.9 , 1018.2 , 1016.7 ] )
1054+ . dashStyle ( . shortDot)
1055+ . tooltip ( AATooltip ( )
1056+ . valueSuffix ( " mb " ) )
1057+
1058+ let element3 = AASeriesElement ( )
1059+ . name ( " 温度 " )
1060+ . type ( . spline)
1061+ . yAxis ( 0 )
1062+ . data ( [ 7.0 , 6.9 , 9.5 , 14.5 , 18.2 , 21.5 , 25.2 , 26.5 , 23.3 , 18.3 , 13.9 , 9.6 ] )
1063+ . tooltip ( AATooltip ( )
1064+ . valueSuffix ( " ℃ " ) )
1065+
1066+ let aaOptions = AAOptions ( )
1067+ . title ( aaTitle)
1068+ . subtitle ( aaSubtitle)
1069+ . colors ( colorsThemeArr)
1070+ . xAxis ( aaXAxis)
1071+ . yAxisArray ( [ yAxis1, yAxis2, yAxis3] )
1072+ . tooltip ( aaTooltip)
1073+ . legend ( aaLegend)
1074+ . series ( [ element1, element2, element3] )
1075+
1076+ return aaOptions
1077+ }
1078+
1079+
8761080}
8771081
8781082
0 commit comments