AndroidPlot 更改绘图中特定点的颜色

AndroidPlot change color of an specific point in plot

我一直在寻找这个问题的答案,但由于找不到任何答案,所以我会 post 这个问题。

我画了一张图,下面的列表显示了一些数据,每行的一个参数都画在图中。

我正在尝试在用户单击列表的其中一个视图时更改点的颜色,以在绘图中反映该行与该点匹配,但我无法复制它。

有什么方法可以得到图形的特定点,改变它的颜色?

提前致谢。

我不知道你正在尝试做的事情是否可行,但你可以尝试在你的情节中添加一个系列,其中包含你想要在用户点击时突出显示的点。完成新的点击后,您只需删除添加的系列并添加一个包含新点的新系列。

添加的系列必须有不同的风格,这样你才能看到“改变的颜色”,并且必须是最后添加的系列,这样它就会在前景中。

希望对您有所帮助


编辑

为了使它适应您的用例,您可以做的是扩展 XYPlot class,创建 SeriesType highlightedPoint 属性 并添加一个方法,例如(不是测试):

public void highlightPoint(Number x, Number y, FormatterType formatter){
    // if there is already a highlighted point we remove it (we want to highlight just one point)
    if(highlightedPoint != null) {
        removeSeries(highlightedPoint);
        highlightedPoint = null;
    }

    // we need to highlight the new point, which means adding a serie on top of the others
    highlightedPoint = new SimpleXYSeries("Highlighted Point");
    highlightedPoint.addFirst(x,y);
    addSeries(highlightedPoint, formatter);
}

每次用户点击您的列表时,您只需在绘图实例上调用此方法。