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

XYSeries.add runs into endless loop #357

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Add to different x/y-pairs with the same big x-value (e.g. using a  long 
representing the current timestamp).

What is the expected output? What do you see instead?
The second call to XYSeries.add(x,y) leads to an endless loop.

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

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

Please provide any additional information below.
See also 
http://stackoverflow.com/questions/17466522/adding-new-values-in-achartengine-ch
arts/18967760#18967760 

Original issue reported on code.google.com by Edgar.Bo...@googlemail.com on 24 Sep 2013 at 6:48

GoogleCodeExporter commented 9 years ago
Sorry, for the typo: I meant of course "Add two different x/y-pairs...."

Original comment by Edgar.Bo...@googlemail.com on 24 Sep 2013 at 6:52

GoogleCodeExporter commented 9 years ago
Just found a new method in Math, which I was not aware of so far, and which 
would solve the problem very easily:

  public synchronized void add(double x, double y) {
    while (mXY.get(x) != null) {
      // add a very small value to x such as data points sharing the same x will
      // still be added. Math.ulp delivers the smallest value which still
      // leads to a change of x.
      x += Math.ulp(x);
    }
    mXY.put(x, y);
    updateRange(x, y);
  }

Same should be done of course in the other add-method, which takes an 
additional index as parameter.

BTW: The updateMaxDifference in IndexXYMap will not work correctly, when 
put(int index, K key, V value) is used, as it compares only the last two 
entries. But the index could point anywhere. I am however not sure about the 
consequences, as I did not check when and why this value is used.

Original comment by Edgar.Bo...@googlemail.com on 28 Sep 2013 at 4:52

GoogleCodeExporter commented 9 years ago
Thanks for reporting this.

Original comment by dandrome...@gmail.com on 31 Oct 2013 at 9:05