gpt4 book ai didi

java - AChartEngine,点击获取图表值

转载 作者:搜寻专家 更新时间:2023-10-31 19:30:49 25 4
gpt4 key购买 nike

我使用 achartengine 编写了一个简单的时间图表。我想要做的是通过单击图表上的点来获取已经绘制的值,这可能吗?

最佳答案

假设 mChartView 是您的 GraphicalView:

mChartView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
SeriesSelection seriesSelection = mChartView.getCurrentSeriesAndPoint();
double[] xy = mChartView.toRealPoint(0);

if (seriesSelection == null) {
Toast.makeText(GraficoMensile.this, "No chart element was clicked", Toast.LENGTH_SHORT)
.show();
} else {
Toast.makeText(
GraficoMensile.this,
"Chart element in series index " + seriesSelection.getSeriesIndex()
+ " data point index " + seriesSelection.getPointIndex() + " was clicked"
+ " closest point value X=" + seriesSelection.getXValue() + ", Y=" + seriesSelection.getValue()
+ " clicked point value X=" + (float) xy[0] + ", Y=" + (float) xy[1], Toast.LENGTH_SHORT).show();
}
}
});

来源: http://code.google.com/p/achartengine/source/browse/trunk/achartengine/demo/org/achartengine/chartdemo/demo/chart/XYChartBuilder.java

关于java - AChartEngine,点击获取图表值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6273796/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com