AAChartModel / AAChartCore

📈📊☕️☕️☕️An elegant modern declarative data visualization chart framework for Android. Extremely powerful, supports line, spline, area, areaspline, column, bar, pie, scatter, angular gauges, arearange, areasplinerange, columnrange, bubble, box plot, error bars, funnel, waterfall and polar chart types.极其精美而又强大的 Android 数据可视化图表框架,支持柱状图、条形图、折线图、曲线图、折线填充图、曲线填充图、气泡图、扇形图、环形图、散点图、雷达图、混合图等各种类型的多达几十种的信息图图表,完全满足工作所需.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

如何自定义左右两侧数据

wangtingshun opened this issue · comments

你好,如下图
image

2.如何去掉X轴基线

commented

其中主要的参考示例:

此示例的 Java 版本的配置方式如下:

    //https://github.com/AAChartModel/AAChartKit/issues/1324
    //https://github.com/AAChartModel/AAChartKit/issues/1330
    public static AAOptions configureTheAxesLabelsFormattersOfDoubleYAxesChart3() {
        AAChart aaChart = new AAChart()
                .backgroundColor(AAColor.White);

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

        AAXAxis aaXAxis = new AAXAxis()
                .visible(true)
                .min(0)
                .categories(new String[]{
                        "Java", "Swift", "Python", "Ruby", "PHP", "Go","C",
                        "C#", "C++", "Perl", "R", "MATLAB", "SQL"
                });

        AAPlotOptions aaPlotOptions = new AAPlotOptions()
                .series(new AASeries()
                        .marker(new AAMarker()
                                .radius(7)//曲线连接点半径,默认是4
                                .symbol(AAChartSymbolType.Circle)//曲线点类型:"circle", "square", "diamond", "triangle","triangle-down",默认是"circle"
                                .fillColor(AAColor.White)//点的填充色(用来设置折线连接点的填充色)
                                .lineWidth(3)//外沿线的宽度(用来设置折线连接点的轮廓描边的宽度)
                                .lineColor("")//外沿线的颜色(用来设置折线连接点的轮廓描边颜色,当值为空字符串时,默认取数据点或数据列的颜色)
                        ));

        AAYAxis yAxis1 = new AAYAxis()
                .visible(true)
                .lineWidth(1)
                .tickPositions(new Object[]{0, 50, 100, 150, 200})
                .labels(new AALabels()
                        .enabled(true)
                        .style(new AAStyle()
                                .color("DodgerBlue"))
                        .formatter("function () {\n" +
                                "       var yValue = this.value;\n" +
                                "       var unitStr = \"\";\n" +
                                "       if (yValue == 0) {\n" +
                                "           unitStr = \"\";\n" +
                                "       }\n" +
                                "       var formattedYValue = (yValue / 1000).toFixed(3) + unitStr;\n" +
                                "       return formattedYValue;\n" +
                                "   }"))//Y轴文字数值为 0 的时候, 不显示单位
                .gridLineWidth(0)
                .title(new AATitle()
                        .text("以「千」为单位")
                        .style(AAStyle.style("DodgerBlue", 14, AAChartFontWeightType.Bold)));

        AAYAxis yAxis2 = new AAYAxis()
                .visible(true)
                .lineWidth(1)
                .tickPositions(new Object[]{0, 50, 100, 150, 200})
                .labels(new AALabels()
                        .enabled(true)
                        .style(new AAStyle()
                                .color(AAColor.Red))
                        .formatter("function () {\n" +
                                "       var yValue = this.value;\n" +
                                "       var unitStr = \"\";\n" +
                                "       if (yValue == 0) {\n" +
                                "           unitStr = \"\";\n" +
                                "       }\n" +
                                "       var formattedYValue = (yValue / 10000).toFixed(4) + unitStr;\n" +
                                "       return formattedYValue;\n" +
                                "   }"))//Y轴文字数值为 0 的时候, 不显示单位
                .gridLineWidth(0)
                .title(new AATitle()
                        .text("以『万』为单位")
                        .style(AAStyle.style(AAColor.Red, 14, AAChartFontWeightType.Bold)))
                .opposite(true)
                ;

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

        AASeriesElement[] seriesArr = {
                new AASeriesElement()
                        .name("2020")
                        .type(AAChartType.Spline)
                        .lineWidth(7)
                        .color(AAGradientColor.DeepSea)
                        .borderRadius(4)
                        .yAxis(1)
                        .data(new Object[]{
                        0, 71.5, 106.4, 129.2, 144.0, 176.0,
                        135.6, 148.5, 216.4, 194.1, 95.6, 54.4
                }),
                new AASeriesElement()
                        .name("2021")
                        .type(AAChartType.Spline)
                        .lineWidth(7)
                        .color(AAGradientColor.Sanguine)
                        .yAxis(0)
                        .data(new Object[]{
                        135.6, 148.5, 216.4, 194.1, 95.6, 54.4,
                        0, 71.5, 106.4, 129.2, 144.0, 176.0
                })
        };

        AAOptions aaOptions = new AAOptions()
                .chart(aaChart)
                .title(aaTitle)
                .plotOptions(aaPlotOptions)
                .xAxis(aaXAxis)
                .yAxisArray(new AAYAxis[]{yAxis1, yAxis2})
                .tooltip(aaTooltip)
                .series(seriesArr);

        return aaOptions;
    }

demo 中有此示例, 下载运行查看即可.

commented
//https://github.com/AAChartModel/AAChartKit/issues/901
//https://github.com/AAChartModel/AAChartKit/issues/952
public static AAOptions configureTheAxesLabelsFormattersOfDoubleYAxesChart() {
    ...
    ...
}

//https://github.com/AAChartModel/AAChartKit/issues/1324
public static AAOptions configureTheAxesLabelsFormattersOfDoubleYAxesChart2() {
    ...
    ...
}

//https://github.com/AAChartModel/AAChartKit/issues/1324
//https://github.com/AAChartModel/AAChartKit/issues/1330
public static AAOptions configureTheAxesLabelsFormattersOfDoubleYAxesChart3() {
    ...
    ...
}

Java 版本的 demo 中, 这三个是相似关联的双 Y 轴示例, 可对比参考查看.

commented

2.如何去掉X轴基线

设置 Y 轴轴线的宽度为 0 即可.