Android 显示/隐藏点标签批次

Android 显示/隐藏点标签批次,android,charts,androidplot,Android,Charts,Androidplot,当我的图表获得大量数据时,点标签相互重叠,因此我想给用户一个选项,通过单击按钮将其关闭,但我在文档中找不到有关如何执行此操作的任何信息。以下是创建图表时如何设置点标签 BarFormatter series1Format = new BarFormatter(Color.rgb(51, 181, 229), Color.TRANSPARENT);' PointLabelFormatter plf = new PointLabelFormatter(); plf.getTextPaint().s

当我的图表获得大量数据时,点标签相互重叠,因此我想给用户一个选项,通过单击按钮将其关闭,但我在文档中找不到有关如何执行此操作的任何信息。以下是创建图表时如何设置点标签

BarFormatter series1Format = new BarFormatter(Color.rgb(51, 181, 229), Color.TRANSPARENT);'
PointLabelFormatter  plf = new PointLabelFormatter();
plf.getTextPaint().setTextSize(18);
plf.getTextPaint().setColor(Color.BLACK);
series1Format.setPointLabelFormatter(plf);

您是否尝试在BarFormatter实例中将PointLabelFormatter设置为null

series1format.setPointLabelFormatter(null);
然后,要重新打开标签,只需使用原始方法将其添加回:

series1Format.setPointLabelFormatter(plf);

现在确定这是否是打开/关闭点标签的最佳方法,但如果有效:)

private void TogglePointLabelVisibility(布尔显示标签)
{
BarFormatter系列1格式=新的BarFormatter();
如果(显示标签)
{
series1Format=新的条形格式化程序(Color.rgb(51181229),Color.TRANSPARENT);
PointLabelFormatter plf=新的PointLabelFormatter();
plf.getTextPaint().setTextSize(18);
plf.getTextPaint().setColor(Color.BLACK);
系列1格式设定点标签格式(plf);
}
其他的
{
series1Format.setPointLabelFormatter(空);
}
SeriesAndFormatterList renderer=plot.getSeriesAndFormatterListForRenderer(BarRenderer.class);
setFormatter(series1、series1Format);
}
private void TogglePointLabelVisibility(boolean ShowLabels)
{
    BarFormatter series1Format = new BarFormatter();

    if(ShowLabels)
    {
        series1Format = new BarFormatter(Color.rgb(51, 181, 229), Color.TRANSPARENT);
        PointLabelFormatter  plf = new PointLabelFormatter();
        plf.getTextPaint().setTextSize(18);
        plf.getTextPaint().setColor(Color.BLACK);
        series1Format.setPointLabelFormatter(plf);
    }
    else
    {
        series1Format.setPointLabelFormatter(null);
    }

    SeriesAndFormatterList<XYSeries, XYSeriesFormatter> renderer = plot.getSeriesAndFormatterListForRenderer(BarRenderer.class);
    renderer.setFormatter(series1, series1Format);

}