Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support triple Y axes chart (支持三重 Y 轴图表📈📊) #763

Closed
AAChartModel opened this issue Oct 24, 2019 · 7 comments
Closed

Support triple Y axes chart (支持三重 Y 轴图表📈📊) #763

AAChartModel opened this issue Oct 24, 2019 · 7 comments
Labels

Comments

@AAChartModel
Copy link
Owner

AAChartModel commented Oct 24, 2019

more than double Y axes

@AAChartModel
Copy link
Owner Author

configure AAOptions instance object

- (AAOptions *)configureTripleYAxesMixedChart {
    NSArray *colorsThemeArr = @[@"red",@"mediumspringgreen",@"deepskyblue",];
    
    AATitle *aaTitle = AATitle.new
    .textSet(@"东京月平均天气数据");
    
    AASubtitle *aaSubtitle = AASubtitle.new
    .textSet(@"数据来源: WorldClimate.com");
        
    AAXAxis *aaXAxis = AAXAxis.new
    .visibleSet(true)
    .minSet(@0)
    .categoriesSet(@[@"一月", @"二月", @"三月", @"四月", @"五月", @"六月",
                     @"七月", @"八月", @"九月", @"十月", @"十一月", @"十二月"]);
    
    AAYAxis *yAxis1 = AAYAxis.new
    .visibleSet(true)
    .gridLineWidthSet(@0)
    .labelsSet(AALabels.new
               .enabledSet(true)//设置 y 轴是否显示数字
               .formatSet(@"{value}°C")
               .styleSet(AAStyle.new
                         .colorSet(colorsThemeArr[2])//yAxis Label font color
              ))
    .titleSet(AAAxisTitle.new
              .textSet(@"温度")
              .styleSet(AAStyle.new
                        .colorSet(colorsThemeArr[2])))
    .oppositeSet(true);
    

    AAYAxis *yAxis2 = AAYAxis.new
    .visibleSet(true)
    .gridLineWidthSet(@0)
    .labelsSet(AALabels.new
               .enabledSet(true)//设置 y 轴是否显示数字
               .formatSet(@"{value}°mm")
               .styleSet(AAStyle.new
                         .colorSet(colorsThemeArr[0])//yAxis Label font color
    ))
    .titleSet(AAAxisTitle.new
              .textSet(@"降雨量")
              .styleSet(AAStyle.new
              .colorSet(colorsThemeArr[0])));
    
    AAYAxis *yAxis3 = AAYAxis.new
    .visibleSet(true)
    .gridLineWidthSet(@0)
    .labelsSet(AALabels.new
                .enabledSet(true)//设置 y 轴是否显示数字
                .formatSet(@"{value}°mb")
                .styleSet(AAStyle.new
                          .colorSet(colorsThemeArr[1])//yAxis Label font color
     ))
    .titleSet(AAAxisTitle.new
               .textSet(@"海平面气压")
               .styleSet(AAStyle.new
               .colorSet(colorsThemeArr[1])))
    .oppositeSet(true);

    AATooltip *aaTooltip = AATooltip.new
    .enabledSet(true)
    .sharedSet(true);
    
    AALegend *aaLegend = AALegend.new
    .enabledSet(true)
    .floatingSet(true)
    .layoutSet(AAChartLayoutTypeVertical)
    .alignSet(AAChartAlignTypeLeft)
    .xSet(@80)
    .verticalAlignSet(AAChartVerticalAlignTypeTop)
    .ySet(@55);
    
    AASeriesElement *element1 = AASeriesElement.new
    .nameSet(@"降雨量")
    .typeSet(AAChartTypeColumn)
    .yAxisSet(@1)
    .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])
    .tooltipSet(AATooltip.new
                .valueSuffixSet(@" mm"));
    
    AASeriesElement *element2 = AASeriesElement.new
    .nameSet(@"海平面气压")
    .typeSet(AAChartTypeSpline)
    .yAxisSet(@2)
    .dataSet(@[@1016, @1016, @1015.9, @1015.5, @1012.3, @1009.5, @1009.6, @1010.2, @1013.1, @1016.9, @1018.2, @1016.7])
    .dashStyleSet(AAChartLineDashStyleTypeShortDot)
    .tooltipSet(AATooltip.new
                .valueSuffixSet(@" mb"));
    
    AASeriesElement *element3 = AASeriesElement.new
    .nameSet(@"温度")
    .typeSet(AAChartTypeSpline)
    .yAxisSet(@0)
    .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])
    .tooltipSet(AATooltip.new
                .valueSuffixSet(@""));
    
    AAOptions *aaOptions = AAOptions.new
    .titleSet(aaTitle)
    .subtitleSet(aaSubtitle)
    .colorsSet(colorsThemeArr)
    .xAxisSet(aaXAxis)
    .yAxisSet((id)@[yAxis1,yAxis2,yAxis3])
    .tooltipSet(aaTooltip)
    .legendSet(aaLegend)
    .seriesSet(@[element1,element2,element3])
    ;
    return aaOptions;
}

final infographic

  • portrait
    image

  • landscape
    image

@AAChartModel AAChartModel changed the title Support multiple Y axes chart (支持多 Y 轴图表📈📊) Support triple Y axes chart (支持三重 Y 轴图表📈📊) Oct 24, 2019
@AAChartModel
Copy link
Owner Author

AAChartModel commented Oct 24, 2019

double y axes chart refer to issue #759

@clj12081103
Copy link

请问下Y轴的名称怎么现在在y轴上方,而不是左右两边

@clj12081103
Copy link

我设置了AAChartAlignType.Center,会超出屏幕,只能看到一点点

@AAChartModel
Copy link
Owner Author

可以通过 AAChart 类(注意不是 AAChartModel)的以下属性

AAPropStatementAndPropSetFuncStatement(strong, AAChart, NSArray     *, margin)//  图表外边缘和绘图区域之间的边距。 数组中的数字分别表示顶部,右侧,底部和左侧 ([👆,👉,👇,👈])。 也可以使用 marginTop,marginRight,marginBottom 和 marginLeft 来设置某一个方向的边距。
AAPropStatementAndPropSetFuncStatement(strong, AAChart, NSNumber    *, marginTop) //👆
AAPropStatementAndPropSetFuncStatement(strong, AAChart, NSNumber    *, marginRight) //👉
AAPropStatementAndPropSetFuncStatement(strong, AAChart, NSNumber    *, marginBottom) //👇
AAPropStatementAndPropSetFuncStatement(strong, AAChart, NSNumber    *, marginLeft) //👈

来调整图表的外边缘与绘图区域之间的边距,避免图表文字被遮挡

@AAChartModel
Copy link
Owner Author

参见此问题 #807

@clj12081103
Copy link

抱歉大佬,我用的是kotlin版本的,提问题提错地方了,我看了一下,kotlin版本的AAChart类没有这个属性

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants