weixin_39778003
weixin_39778003
2021-01-10 15:48

双X轴 单Y轴怎么处理?

如题

该提问来源于开源项目:AAChartModel/AAChartKit

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

6条回答

  • weixin_39522103 weixin_39522103 4月前

    配置 AAOptions

    objc
    - (AAOptions *)customDoubleXAxesChart {
        NSDictionary *gradientColorDic1 =
        [AAGradientColor gradientColorWithDirection:AALinearGradientDirectionToTop
                                   startColorString:@"#7052f4"//颜色字符串设置支持十六进制类型和 rgba 类型
                                     endColorString:@"#00b0ff"];
    
        NSDictionary *gradientColorDic2 =
        [AAGradientColor gradientColorWithDirection:AALinearGradientDirectionToTop
                                   startColorString:@"#EF71FF"//颜色字符串设置支持十六进制类型和 rgba 类型
                                     endColorString:@"#4740C8"];
    
        NSArray *categories = @[
            @"0-4", @"5-9", @"10-14", @"15-19",
            @"20-24", @"25-29", @"30-34", @"35-39", @"40-44",
            @"45-49", @"50-54", @"55-59", @"60-64", @"65-69",
            @"70-74", @"75-79", @"80-84", @"85-89", @"90-94",
            @"95-99", @"100 + ",];
    
        AAOptions *aaOptions = AAOptions.new
        .chartSet(AAChart.new
                  .typeSet(AAChartTypeBar)
                  )
        .titleSet(AATitle.new
                  .textSet(@"Population pyramid for Germany, 2015"))
        .xAxisSet((id)@[
            AAXAxis.new
            .reversedSet(true)
            .categoriesSet(categories)
            .labelsSet(AALabels.new
                       .enabledSet(true)
                       .stepSet()),
            AAXAxis.new
            .reversedSet(true)
            .oppositeSet(true)
            .categoriesSet(categories)
            .linkedToSet()
            .labelsSet(AALabels.new
                       .enabledSet(true)
                       .stepSet()),
        ])
        .yAxisSet(AAYAxis.new
                  .visibleSet(true)
                  .gridLineWidthSet()
                  .titleSet(AAAxisTitle.new
                            .textSet(@"收入"))
                  .labelsSet(AALabels.new
                             .formatterSet((function () {
            return (Math.abs(this.value) / 1000000) + 'M';
        }
                                                     ))))
        .tooltipSet(AATooltip.new
                    .enabledSet(true)
                    .sharedSet(false)
                    .formatterSet((function () {
            return '<b>' + this.series.name + ', age ' + this.point.category + '</b><br>' +
            '人口: ' + Highcharts.numberFormat(Math.abs(this.point.y), 0);
        }
                                            )))
        .plotOptionsSet(AAPlotOptions.new
                        .seriesSet(AASeries.new
                                   .animationSet(AAAnimation.new
                                                 .easingSet(AAChartAnimationBounce)
                                                 .durationSet()
                                                 )
                                   .stackingSet(AAChartStackingTypeNormal)
                                   )
                        )
        .seriesSet(@[
            AASeriesElement.new
            .nameSet(@"Men")
            .colorSet((id)gradientColorDic1)
            .dataSet(@[@-1746181, @-1884428, @-2089758, @-2222362, @-2537431, @-2507081, @-2443179,
                       @-2664537, @-3556505, @-3680231, @-3143062, @-2721122, @-2229181, @-2227768,
                       @-2176300, @-1329968, @-836804, @-354784, @-90569, @-28367, @-3878]),
            AASeriesElement.new
            .nameSet(@"Women")
            .colorSet((id)gradientColorDic2)
            .dataSet(@[, , , , , , , ,
                       , , , , , , , ,
                       , , , , ]),
        ])
        ;
    
        return aaOptions;
    }
    
    
    点赞 评论 复制链接分享
  • weixin_39522103 weixin_39522103 4月前

    最终图形结果 (landscape)

    image

    点赞 评论 复制链接分享
  • weixin_39522103 weixin_39522103 4月前

    最终图形结果 (portrait)

    image

    点赞 评论 复制链接分享
  • weixin_39522103 weixin_39522103 4月前

    修改 AAChartTypeBar 为 AAChartTypeColumn,得到双X轴柱形图

    landscape

    image

    portrait

    image

    点赞 评论 复制链接分享
  • weixin_39960147 weixin_39960147 4月前

    Double x axis. If the array data of two X axes.. how to get the data of the second X axis

    点赞 评论 复制链接分享
  • weixin_39522103 weixin_39522103 4月前

    Double x axis. If the array data of two X axes.. how to get the data of the second X axis

    objc
        NSArray <aaxaxis>* aaXAxisArr = (NSArray <aaxaxis>*)aaOptions.xAxis;
        AAXAxis *aaXAxisElement0 = aaXAxisArr[0];
        AAXAxis *aaXAxisElement1 = aaXAxisArr[1];
    </aaxaxis></aaxaxis>
    点赞 评论 复制链接分享

相关推荐