wangyao5 / achartengine

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

Chart labels in x axis #141

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What is the expected output? What do you see instead?
It  is showing Labels 2,4 6 with the new added labels. see the marked area in 
attached image. 

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

 XYMultipleSeriesRenderer renderer = getBarDemoRenderer();
      setChartSettings(renderer);
      intent = ChartFactory.getBarChartIntent(this, getBarDemoDataset(), renderer, Type.DEFAULT);
      Dialog dlg = new Dialog(this);
      DisplayMetrics displaymetrics = new DisplayMetrics();         
      getWindowManager().getDefaultDisplay().getMetrics(displaymetrics);         
      int ht = displaymetrics.heightPixels;        
      int wt = displaymetrics.widthPixels; 
      dlg.setTitle("Gross Area Distribution");
      dlg.setContentView(ChartFactory.getBarChartView(this, getBarDemoDataset(), renderer, Type.DEFAULT), new LayoutParams(wt-200,ht-150));
      dlg.show();

public XYMultipleSeriesRenderer getBarDemoRenderer() {
    XYMultipleSeriesRenderer renderer = new XYMultipleSeriesRenderer();
    renderer.setAxisTitleTextSize(16);
    renderer.setChartTitleTextSize(20);
    renderer.setLabelsTextSize(15);
    renderer.setLegendTextSize(15);
    renderer.setPointSize(5f);
    renderer.setLegendHeight(0);
    renderer.setShowLegend(false);
    renderer.setMargins(new int[] {20, 30, 15, 20});
    SimpleSeriesRenderer r = new SimpleSeriesRenderer();
    r.setColor(Color.BLUE);
    r.setDisplayChartValues(true);
    renderer.addSeriesRenderer(r);

    renderer.addXTextLabel(1, "Common Area");
    renderer.addXTextLabel(2, "Usable Area");
    renderer.addXTextLabel(3, "External Area");
    renderer.addXTextLabel(4, "Vertical Area");
    renderer.addXTextLabel(5, "Gross Area");
    return renderer;
  }

 private void setChartSettings(XYMultipleSeriesRenderer renderer) {
    renderer.setChartTitle("");
    renderer.setXTitle("Items");
    renderer.setYTitle("Area (Sq.Ft.)");
    renderer.setXAxisMin(0);
    renderer.setXAxisMax(6);
    renderer.setYAxisMin(0);
    renderer.setYAxisMax(13000);
    renderer.setBarSpacing(1);
    renderer.setPanEnabled(false, false);
  }

private XYMultipleSeriesDataset getBarDemoDataset() {
    XYMultipleSeriesDataset dataset = new XYMultipleSeriesDataset();

    CategorySeries series = new CategorySeries("");
    series.add(12546.45);
    series.add(12421.45);
    series.add(520.15);
    series.add(195.85);
    series.add(10956.34);
    dataset.addSeries(series.toXYSeries());

    return dataset;
  }

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

Please provide any additional information below.

Is it possible show different values in a single series with different colors?

Original issue reported on code.google.com by sr.sh...@gmail.com on 28 Sep 2011 at 7:10

Attachments:

GoogleCodeExporter commented 9 years ago
Hello,

 Sorry for the first problem, It is fine by settings renderer.setXLabels(0)

The second one is that, I want show the above chart with different colors. 
There are 5 bars in the chart. I want to show those in 5 color rather that the 
blue color. 

Also, Can I avoid displaying series value if it 0?

Original comment by sr.sh...@gmail.com on 4 Oct 2011 at 8:40

GoogleCodeExporter commented 9 years ago
Use renderer.setXLabels(0) indeed.
Create different series for getting different colors.

Original comment by dandrome...@gmail.com on 26 Oct 2011 at 5:25

GoogleCodeExporter commented 9 years ago

Original comment by dandrome...@gmail.com on 26 Oct 2011 at 5:28