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

CombinedTemperatureChart.java at r517 crashes #297

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Compile and run r517
2. Choose Combined temperature
3. Crashes

Following error log is produced

    FATAL EXCEPTION: main
    java.lang.IndexOutOfBoundsException: Invalid index 1, size is 0
        at java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:251)
        at java.util.ArrayList.add(ArrayList.java:143)
        at org.achartengine.util.IndexXYMap.put(IndexXYMap.java:42)
        at org.achartengine.model.XYSeries.add(XYSeries.java:155)
        at org.achartengine.chartdemo.demo.chart.CombinedTemperatureChart.execute(CombinedTemperatureChart.java:100)
        at org.achartengine.chartdemo.demo.ChartDemo.onListItemClick(ChartDemo.java:107)
        at android.app.ListActivity$2.onItemClick(ListActivity.java:319)

This is caused by 

[CombinedTemperatureChart.java]
    XYValueSeries sunSeries = new XYValueSeries("Sunshine hours");
    sunSeries.add(1, 35, 4.3);

It will trigger function XYSeries's add(int index, double x, double y)

If I change it to 

    XYValueSeries sunSeries = new XYValueSeries("Sunshine hours");
    sunSeries.add(1., 35, 4.3);

It works fine, as function XYValueSeries's add(double x, double y, double 
value) will be triggered.

I tested with r439. No crash happens. This is because in r439,  XYSeries's 
add(int index, double x, double y) is not added yet.

So, is sunSeries.add(1., 35, 4.3) as correct code, or should it be considered 
as temporary workaround?

Original issue reported on code.google.com by yancheng...@gmail.com on 15 Apr 2013 at 11:40

GoogleCodeExporter commented 9 years ago
Good catch!

Original comment by 4viewsoft@gmail.com on 13 May 2013 at 6:01