harisrinivasr / achartengine

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

TimeChart will spin endlessly with empty dataset in getXLabels #221

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Create an empty TimeSeries
2. Create a chart with the empty TimeSeries
3. Run program and see the chart never display

What is the expected output? What do you see instead?

The chart is never drawn because getXLabels() spins forever.

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

 @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.graph_viewer);

        XYMultipleSeriesRenderer mRenderer = new  XYMultipleSeriesRenderer();
        mRenderer.setZoomButtonsVisible(false);
        mRenderer.setChartTitle("Title");
        mRenderer.setXTitle("Time");
        mRenderer.setYTitle("Heart Rate");
        mRenderer.setShowGrid(true);
        mRenderer.setShowLabels(false);
        mRenderer.addSeriesRenderer(new XYSeriesRenderer());

        XYSeries mLifesignSeries = new TimeSeries("Time");
        XYMultipleSeriesDataset dataset = new XYMultipleSeriesDataset();
        dataset.addSeries(mLifesignSeries);

        mLineChart = ChartFactory.getTimeChartView(this, dataset, mRenderer, "HH:mm");
        ((LinearLayout) findViewById(R.id.graph_container)).addView(mLineChart);
     }

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

The following code seems to be the culprit. I haven't done extensive testing, 
but I suspect count is 0 here. So cycleMath is always < (cycle / 2).

    final double cycleMath = (max - min) / count;
    double cycle = DAY;

    if (cycleMath <= DAY) {
      while (cycleMath < cycle / 2) {
        cycle = cycle / 2;
      }
    } else {
      while (cycleMath > cycle) {
        cycle = cycle * 2;
      }
    }

Original issue reported on code.google.com by mrsl...@gmail.com on 11 Jun 2012 at 10:12

GoogleCodeExporter commented 9 years ago
Great catch, thanks!
Fixed in SVN rev. r423.

Original comment by dandrome...@gmail.com on 13 Jun 2012 at 10:53