使用时间序列在散点图上获得重点

时间:2013-10-15 12:49:11

标签: achartengine

使用TimeSeries缩放或平移散点图后,将根据屏幕上的内容计算pointIndex点。

如果系列中有10个项目,则首次显示图表时,项目1位于pointIndex 0处。项目2位于pointIndex 1等处。但是,一旦缩放或平移,则pointIndex以什么为开始显示,而不是系列中项目的索引。

有没有人想办法获得点的系列索引值而不是平移/缩放的索引值?

1 个答案:

答案 0 :(得分:1)

我通过改变名为 getRange XYSeries 的方法来解决这个问题。

public synchronized RangeHolderWithDiff getRange(double start, double stop,
  boolean beforeAfterPoints) {
int diff = 0;
if (beforeAfterPoints) {
  // we need to add one point before the start and one point after the end
  // (if
  // there are any)
  // to ensure that line doesn't end before the end of the screen

  // this would be simply: start = mXY.lowerKey(start) but NavigableMap is
  // available since API 9
  SortedMap<Double, Double> headMap = mXY.headMap(start);
  if (!headMap.isEmpty()) {
    start = headMap.lastKey();
    diff = headMap.size();
    System.out.println("DIFF IS " + diff);
  }

  // this would be simply: end = mXY.higherKey(end) but NavigableMap is
  // available since API 9
  // so we have to do this hack in order to support older versions
  SortedMap<Double, Double> tailMap = mXY.tailMap(stop);
  if (!tailMap.isEmpty()) {
    Iterator<Double> tailIterator = tailMap.keySet().iterator();
    Double next = tailIterator.next();
    if (tailIterator.hasNext()) {
      stop = tailIterator.next();
    } else {
      stop += next;
    }
  }
}
RangeHolderWithDiff mRangeHolderWithDiff = new RangeHolderWithDiff();
mRangeHolderWithDiff.indexDiff = diff;
mRangeHolderWithDiff.sortedMap = mXY.subMap(start, stop);
return mRangeHolderWithDiff;

}

diff变量为您提供额外的x值计数,我正在尝试将此参数添加到touchAreas。如果我能做到这一点,我将编辑我的答案。祝你好运。