2013-10-15 1 views
1

TimeSeries에서 분산 형 차트를 확대/축소하거나 패닝 한 후 화면의 내용을 기반으로 pointIndex 점이 계산됩니다.TimeSeries에서 분산 형 차트의 요점 얻기

차트에 처음으로 표시 될 때 10 개의 항목이있는 경우 항목 1은 pointIndex 0에 있습니다. 항목 2는 pointIndex 1에 있습니다. 그러나 일단 확대 또는 이동하면 pointIndex는 시리즈의 항목 인덱스가 아니라 SHOWN입니다.

누군가가 포인트의 시리즈 인덱스 값을 얻는 방법을 알았지 만 이동/확대/축소 된 인덱스 값을 가져 오는 방법을 찾지 못했습니까?

답변

1

XYSeriesgetRange이라는 메서드를 변경하여 알아 냈습니다.

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이 매개 변수를 추가하려합니다. 내가 할 수 있으면 나는 나의 대답을 편집 할 것이다. 행운을 빕니다.