chenboling / achartengine

Automatically exported from code.google.com/p/achartengine
0 stars 0 forks source link

XYValueSeries.clear (or remove) generates a wrong .getMaxValue #408

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1.to initiate the XYValueSeries with some values. In this case getMaxValue 
works correctly. 
2.to clear the series with "clear" or "remove" until the series is empty. 
3.to rewrite the series again with some values. 
4.the Values are correct in the series, but getMaxValue returns the possibly 
maximum value of "double", which is 1.7976...E308. 

What is the expected output? What do you see instead?
The expected output of getMaxValue is to be the real max value in the series 
after the rewritting. Instead I see the max one of "double". 

Please provide a source code snippet that we can use to replicate the
issue.
{

cali_snr_dataset = new XYMultipleSeriesDataset();  

cali_snr_xy = new XYValueSeries("SNR of the SPAD array");

short row, column=0;

////////to initialize the array of 1024 (32x32) data with increasing 
values///////////
for(column = 0;column < 32;column++){
    for(row = 0;row < 32; row++){       
        cali_snr_xy.add((double)column, (double)row, (double)((column*32+row)));

    }
}

cali_snr_dataset.addSeries(cali_snr_xy);

int[] cali_snr_colors = new int[] {Color.YELLOW};   
PointStyle[] styles = new PointStyle[] { PointStyle.CIRCLE};
cali_snr_renderer = buildRenderer(cali_snr_colors, styles, true);    

setChartSettings(cali_snr_renderer, "SNR of the SPAD array", "Row", "Column", 
-0.9, 31.9, -0.9, 31.9, Color.WHITE, Color.WHITE, Color.BLACK);  
cali_snr_renderer.setShowGrid(true);
cali_snr_renderer.setGridColor(Color.GREEN);
cali_snr_renderer.setYLabels(17);
cali_snr_renderer.setXLabels(17);

//////////to draw the bubble plot///////////
LinearLayout layout_cali_snr = (LinearLayout) 
findViewById(R.id.view_plot_cali_snr);
view_cali_snr = ChartFactory.getBubbleChartView(MainActivity.this, 
cali_snr_dataset, cali_snr_renderer);
layout_cali_snr.addView(view_cali_snr);   

/////after the initialization, to check the Max/Min values. So far it is 
correct and I get 1023 as Max and 0 as Min. 
System.out.println("**************************");
System.out.println(cali_snr_xy.getMaxValue());
System.out.println(cali_snr_xy.getMinValue());

///////to clear the array and reassign with decreasing values//////////
cali_snr_xy.clear(); //or remove 1024 times. Both have the same effect.
for(column = 0;column < 32;column++){
    for(row = 0;row < 32; row++){       
        cali_snr_xy.add((double)column, (double)row, (double)(1023-(column*32+row)));                   
    }
}

///////////check the 1024 new values in the array. they are all correct, varing 
from 1023 to 0. So far looks also correct.////////////
System.out.println("***************");
int i;
for(i=0;i<1024;i++){
    System.out.println(cali_snr_xy.getValue(i));
}                   
//////////However if I check the Max and Min, Max is wrong. it prints out 
1.7976xxxE308 as Max/////////////////////////
System.out.println("----------------");
System.out.println(cali_snr_xy.getMaxValue());
System.out.println(cali_snr_xy.getMinValue());

/////to replot//////////////
view_cali_snr.repaint();

}

What version of the product binary library are you using?
1.10

Please provide any additional information below.
Printout of the code above:
05-14 10:37:28.199: I/System.out(3277): **************************
05-14 10:37:28.219: I/System.out(3277): 1023.0 //after the first 
initialization, correct!!!
05-14 10:37:28.219: I/System.out(3277): 0.0
05-14 10:37:28.319: D/dalvikvm(3277): GC_FOR_ALLOC freed 512K, 11% free 
4431K/4972K, paused 3ms, total 3ms
05-14 10:37:28.349: I/System.out(3277): ***************
05-14 10:37:28.349: I/System.out(3277): 1023.0 //all the printed updated values 
correct!
05-14 10:37:28.349: I/System.out(3277): 1022.0
05-14 10:37:28.349: I/System.out(3277): 1021.0
05-14 10:37:28.349: I/System.out(3277): 1020.0
.
.here are the decreasing values. 
.
05-14 10:37:28.449: I/System.out(3277): 2.0
05-14 10:37:28.449: I/System.out(3277): 1.0
05-14 10:37:28.449: I/System.out(3277): 0.0
05-14 10:37:28.449: I/System.out(3277): ----------------
05-14 10:37:28.449: I/System.out(3277): 1.7976931348623157E308 //BUT, here MAX 
is WRONG!!!
05-14 10:37:28.449: I/System.out(3277): 0.0

Original issue reported on code.google.com by eeming...@gmail.com on 16 May 2014 at 12:58

GoogleCodeExporter commented 9 years ago

Original comment by dandrome...@gmail.com on 20 May 2014 at 10:40