goodev / achartengine

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

Legend overlaps X axis labels (or worse) with larger font sizes #434

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Use attached source code

What is the expected output? What do you see instead?
The legend should not overlap the X axis title as it does.

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

package com.gamesbybill.achartengineexperiments;

import android.graphics.Point;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.widget.LinearLayout;

import org.achartengine.ChartFactory;
import org.achartengine.model.XYMultipleSeriesDataset;
import org.achartengine.model.XYSeries;
import org.achartengine.renderer.XYMultipleSeriesRenderer;
import org.achartengine.renderer.XYSeriesRenderer;

import java.util.Random;

public class MyActivity extends ActionBarActivity {

  private final static Random rand = new Random();

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_my);
  }

  @Override
  protected void onResume() {
    super.onResume();
    Point p = new Point();
    p.x = getWindowManager().getDefaultDisplay().getWidth();
    p.y = getWindowManager().getDefaultDisplay().getHeight();
    int maxDim = p.x > p.y ? p.x : p.y;
    int fontSize = maxDim / 60;
    LinearLayout layout = (LinearLayout) findViewById(R.id.graph_surface);
    XYSeries series1 = new XYSeries("Series 1");
    setXYSeriesData(series1);
    XYSeries series2 = new XYSeries("Series 2");
    setXYSeriesData(series2);
    XYMultipleSeriesRenderer renderer = new XYMultipleSeriesRenderer();
    renderer.setLabelsTextSize(fontSize);
    renderer.setLegendTextSize(fontSize * 2);
    renderer.setShowLabels(true);
    renderer.setAxisTitleTextSize(fontSize);
    renderer.addSeriesRenderer(new XYSeriesRenderer());
    renderer.addSeriesRenderer(new XYSeriesRenderer());
    renderer.setXTitle("X Title");
    renderer.setYTitle("Y Title");
    XYMultipleSeriesDataset dataSet = new XYMultipleSeriesDataset();
    dataSet.addSeries(series1);
    dataSet.addSeries(series2);
    renderer.setYLabelsAngle(270);
    layout.addView(ChartFactory.getLineChartView(this, dataSet, renderer));
  }

  private void setXYSeriesData(XYSeries r) {
    int start = 1;
    int end = 10;
    int value = 0;
    for (int i = start; i < end; i++) {
      r.add(i, value);
      int change = rand.nextInt(15) - 7;
      value += change;
    }
  }
}

What version of the product binary library are you using?
Tested on both trunk and 1.1.0

Please provide any additional information below.
More detail posted on my blog, if it helps:
http://billdoesgames.blogspot.com/2014/09/formatting-charts-on-android-with.html

Original issue reported on code.google.com by william....@gmail.com on 10 Sep 2014 at 8:09

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
This bug shows up on Android 4.4.4 (e.g. Samsung Galaxy S5), but not on 4.4.2, 
4.2.x or 2.3.6. The emulator only supports 4.4.2 (API 19), so there is no way 
to select 4.4.3 or 4.4.4.

Original comment by mkote...@gmail.com on 10 Oct 2014 at 4:09