Android GraphView多个系列在触摸时显示/隐藏特定的线图

时间:2017-05-30 16:35:02

标签: android android-graphview

我正在使用GraphView for Android,多个系列显示2个图表。 是否有可能在触摸时显示/隐藏其中一个图表,因为我无法在网站上找到任何文档?

以下是源代码:

graph = (GraphView) findViewById(R.id.graph);
LineGraphSeries<DataPoint> series = new LineGraphSeries<>(new DataPoint[] {
    new DataPoint(0, 1),
    new DataPoint(1, 5),
    new DataPoint(2, 3),
    new DataPoint(3, 2),
    new DataPoint(4, 6)
});
graph.addSeries(series);

LineGraphSeries<DataPoint> series2 = new LineGraphSeries<>(new DataPoint[] {
    new DataPoint(0, 3),
    new DataPoint(1, 3),
    new DataPoint(2, 6),
    new DataPoint(3, 2),
    new DataPoint(4, 5)
});
graph.addSeries(series2);

1 个答案:

答案 0 :(得分:0)

想出办法,如果有人偶然发现了这个问题。 创建了使用以下内容的自定义切换/按钮:graph.removeSeries()/graph.addSeries(),这应该可以解决问题