paragp / achartengine

AChartEngine is a charting library for Android applications. It currently supports the following chart types: line chart area chart scatter chart time chart bar chart pie chart bubble chart doughnut chart range (high-low) bar chart dial chart / gauge combined (any combination of line, cubic line, scatter, bar, range bar, bubble) chart cubic line chart All the above supported chart types can contain multiple series, can be displayed with the X axis horizontally (default) or vertically and support many other custom features. The charts can be built as a view that can be added to a view group or as an intent, such as it can be used to start an activity. The model and the graphing code is well optimized such as it can handle and display huge number of values. AChartEngine is currently at the 1.0.0 release. New chart types will be added in the following releases. Please keep sending your feedback such as we can continually improve this library. Find us on Facebook, too: http://www.facebook.com/achartengine Read a short introduction to AChartEngine here: http://www.javaadvent.com/2012/12/achartengine-charting-library-for.html Another good tutorial can be read here: http://jaxenter.com/effort-free-graphs-on-android-with-achartengine-46199.html
0 stars 1 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