AAChartCore icon indicating copy to clipboard operation
AAChartCore copied to clipboard

y轴最大值无效

Open CodeWizardX11 opened this issue 1 year ago • 4 comments

image String[] colorsArr = { "#73DDFF", "#9E87FF", "#aecb56", "#fe9a8b", "#F56948", "#9E87FF", "#00ffa2", "#0092f6", "#00d4c7", "#aecb56", "#3A44FB", "#6FE81A",

    };
    AAChartModel aaChartModel = new AAChartModel()
            .legendEnabled(true)//是否显示图例
            .stacking(AAChartStackingType.Normal)
            .colorsTheme(colorsArr);

    /*Custom Tooltip Style --- 自定义图表浮动提示框样式及内容*/
    AAOptions aaOptions = AAOptionsConstructor.configureChartOptions(aaChartModel);


    AATitle aaTitle = new AATitle()
            .text("");

    AASubtitle aaSubtitle = new AASubtitle()
            .text("首次报名年龄段情况")
            .style(new AAStyle()
                    .color("#333")
                    .fontSize(14f)
                    .fontWeight("bold"))
            .align("left");

    AAXAxis aaXAxis = new AAXAxis()
            .lineWidth(0f)
            .visible(true)
            .min(0f)
            .labels(new AALabels()
                    .useHTML(true)
                    .style(new AAStyle()
                            .fontSize(15.f)
                            .fontWeight("400")
                            .color("#333")//轴文字颜色
                    ))
            .categories(new String[]{"一月", "二月", "三月", "四月", "五月", "六月"});


    AAYAxis yAxis1 = new AAYAxis()
            .visible(true)
            .max(100)
            .min(0)
            .gridLineWidth(0f)
            .labels(new AALabels()
                    .enabled(true)//设置 y 轴是否显示数字
                    .format("{value}%")
                    .style(new AAStyle()
                            .color("#333333")//yAxis Label font color
                    ))
            .title(new AATitle()
                    .text("")
                    .style(new AAStyle()
                            .color("#333333")));

    AAYAxis yAxis2 = new AAYAxis()
            .visible(true)
            .gridLineWidth(0f)
            .labels(new AALabels()
                    .enabled(true)//设置 y 轴是否显示数字
                    .format("{value}")
                    .style(new AAStyle()
                            .color("#333333")//yAxis Label font color
                    ))

            .offset(0)
            .title(new AATitle()
                    .align("high")
                    .y(-10)
                    .text("人数(人)")
                    .style(new AAStyle()
                            .color("#333333")))
            .opposite(true);


    AATooltip aaTooltip = new AATooltip()
            .enabled(true)
            .shared(true);

    AALegend aaLegend = new AALegend()
            .enabled(true)
            .floating(true)
            .layout(AAChartLayoutType.Horizontal)
            .align(AAChartAlignType.Center)
            .x(80f)
            .verticalAlign(AAChartVerticalAlignType.Top)
            .y(0f);

    AASeriesElement[] aaSeriesArr = {

            new AASeriesElement()
                    .name("新用户")
                    .type(AAChartType.Column)
                    .yAxis(0)
                    .data(new Object[]{20, 30, 20, 30, 20, 30})
                    .tooltip(new AATooltip()
                            .valueSuffix(" %")

                    )
                    .dataLabels(
                    new AADataLabels()
                            .enabled(true)
                            .format("{y:.2f}%")
                            .style(new AAStyle()
                                    .color("#000000")
                                    .fontSize(12f)
                            )
            )
            ,
            new AASeriesElement()
                    .name("老用户")
                    .type(AAChartType.Column)
                    .yAxis(0)
                    .data(new Object[]{20, 30, 20, 30, 20, 30})
                    .tooltip(new AATooltip()
                            .valueSuffix(" %")
                    )
                    .dataLabels(
                    new AADataLabels()
                            .enabled(true)
                            .format("{y:.2f}%")
                            .style(new AAStyle()
                                    .color("#000000")
                                    .fontSize(12f)
                            )
            ),
            new AASeriesElement()
                    .name("总量")
                    .type(AAChartType.Column)
                    .yAxis(0)
                    .data(new Object[]{60, 40, 60, 40, 60, 40})
                    .tooltip(new AATooltip()
                            .valueSuffix(" %")
                    )
                    .dataLabels(
                    new AADataLabels()
                            .enabled(true)
                            .format("{y:.2f}%")
                            .style(new AAStyle()
                                    .color("#000000")
                                    .fontSize(12f)
                            )
            ),
            new AASeriesElement()
                    .name("海平面气压")
                    .type(AAChartType.Line)
                    .yAxis(1)
                    .data(new Object[]{23, 333, 3333, 22, 333.3, 666})

// .dashStyle(AAChartLineDashStyleType.ShortDot) .tooltip(new AATooltip() .valueSuffix(" 人")), new AASeriesElement() .name("温度") .type(AAChartType.Line) .yAxis(1) .data(new Object[]{11, 77, 999, 4444, 18.2, 444}) .tooltip(new AATooltip() .valueSuffix(" 人")) };

    aaOptions
            .title(aaTitle)
            .subtitle(aaSubtitle)
            .colors(colorsArr)
            .xAxis(aaXAxis)
            .yAxisArray(new AAYAxis[]{yAxis1, yAxis2})
            .tooltip(aaTooltip)
            .legend(aaLegend)
            .series(aaSeriesArr);

    return aaOptions;

image 设置了y轴1最大值为100,显示为120,以上是配置,帮忙看一下是哪里配错了吗

CodeWizardX11 avatar Jun 26 '24 11:06 CodeWizardX11

这个解了吗

artillerymans avatar Oct 22 '24 02:10 artillerymans

compose 使用AndroidView方式创建图表不显示,需要额外配置吗?

我试了下可以显示出来啊

artillerymans avatar Oct 22 '24 02:10 artillerymans

以xml方式引入可以正常,直接compose创建不可以

yanlianhanlin avatar Oct 24 '24 05:10 yanlianhanlin

以xml方式引入可以正常,直接compose创建不可以

没碰到这个问题 我直接AndroidView创建,给数据 正常展示

artillerymans avatar Oct 24 '24 05:10 artillerymans