I found out that:
GraphViewDataInterface[] values = graphSeries.get(0).values;
stops increasing in size when it reaches the maxDataCount set by the appendData function in the GraphViewData class. This is the reason I get the array index out of bounds error. Here's my solution. It's not the nicest looking code, but it seems to work. The original GraphView library declared private final List graphSeries; The .get(0).values is from the List class.
private String[] generateHorlabels(float graphwidth) {
int numLabels = getGraphViewStyle().getNumHorizontalLabels()-1;
if (numLabels < 0) {
numLabels = (int) (graphwidth/(horLabelTextWidth*2));
}
String[] labels = new String[numLabels+1];
double min = getMinX(false);
double max = getMaxX(false);
double temp = 0;
GraphViewDataInterface[] values = graphSeries.get(0).values;
for (int i=0; i<=numLabels; i++) {
if( max < values.length){
temp = min + ((max-min)*i/numLabels);
}else{
temp = (values.length - (max-min)) + ((max-min)*i/numLabels);
}
int rounded =(int)Math.round(temp)-1;
if(rounded < 0){
labels[i] = " ";
}else{
if(values.length > rounded){
labels[i] = values[rounded].getTime();
}else{
labels[i] = " ";
}
}
}
return labels;
}
If you're trying to do the same thing, give it a try, and let me know if something is wrong. I would love some feedback.
Edit: I should add that you also need to have a statement that catches when the graphSeries.size() is 0.