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

What able to change the bar chart type for combined xy graph #210

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. take bar chart on one y axis and take line chart on another y axis
2. default bar chart of stacked is drawn
3.

What is the expected output? What do you see instead?
option of stacked or default chart should be there

Please provide a source code snippet that we can use to replicate the issue.
/**
 * Copyright (C) 2009, 2010 SC 4ViewSoft SRL
 *  
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *  
 *      http://www.apache.org/licenses/LICENSE-2.0
 *  
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.achartengine.chartdemo.demo.chart;

import java.util.ArrayList;
import java.util.List;

import org.achartengine.ChartFactory;

import org.achartengine.chart.BarChart;
import org.achartengine.chart.RangeBarChart;
import org.achartengine.chart.LineChart;
import org.achartengine.chart.PointStyle;
import org.achartengine.model.XYMultipleSeriesDataset;
import org.achartengine.renderer.XYMultipleSeriesRenderer;
import org.achartengine.renderer.XYMultipleSeriesRenderer.Orientation;
import org.achartengine.renderer.XYSeriesRenderer;

import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.graphics.Paint.Align;

/**
 * Multiple temperature demo chart.
 */
public class MultipleTemperatureChart extends AbstractDemoChart {
  /**
   * Returns the chart name.
   * 
   * @return the chart name
   */
  public String getName() {
    return "Temperature and sunshine";
  }

  /**
   * Returns the chart description.
   * 
   * @return the chart description
   */
  public String getDesc() {
    return "The average temperature and hours of sunshine in Crete (line chart with multiple Y scales and axis)";
  }

  /**
   * Executes the chart demo.
   * 
   * @param context the context
   * @return the built intent
   */
  public Intent execute(Context context) {
    String[] titles = new String[] { "Air temperature","Water" ,"India"};
    List<double[]> x = new ArrayList<double[]>();
    for (int i = 0; i < titles.length; i++) {
      x.add(new double[] { 1, 2, 3, 4, 5, 6, 7, 8, 9});
    }
    List<double[]> values = new ArrayList<double[]>();
    values.add(new double[] { 18, 12.5, 13.8, 0, 0, 24.4, 26.4, 26.1, 23.6});
    values.add(new double[] { 12.3, 12.5, 13.8, 16.8, 20.4, 24.4, 26.4, 26.1, 23.6 });
    values.add(new double[] {1, 2, 3, 4, 5, 6, 7, 8, 9});
    int[] colors = new int[] { Color.BLUE, Color.YELLOW ,Color.DKGRAY,Color.DKGRAY};
    PointStyle[] styles = new PointStyle[] { PointStyle.POINT, PointStyle.POINT ,PointStyle.POINT,PointStyle.POINT};
    XYMultipleSeriesRenderer renderer = new XYMultipleSeriesRenderer(4);
    setRenderer(renderer, colors, styles);
    renderer.setOrientation(Orientation.HORIZONTAL);
    int length = renderer.getSeriesRendererCount();
    for (int i = 0; i < length; i++) {
      XYSeriesRenderer r = (XYSeriesRenderer) renderer.getSeriesRendererAt(i);
      r.setLineWidth(3f);
    }
    setChartSettings(renderer, "Average temperature", "Month", "Temperature", 0.5, 12.5, 0, 32,
        Color.LTGRAY, Color.GRAY);
    renderer.setXLabels(12);
    renderer.setYLabels(10);
    renderer.setShowGrid(true);
    renderer.setXLabelsAlign(Align.RIGHT);
    renderer.setYLabelsAlign(Align.RIGHT);
    renderer.setZoomButtonsVisible(true);
    renderer.setPanLimits(new double[] { -10, 20, -10, 40 });
    renderer.setZoomLimits(new double[] { -10, 20, -10, 40 });
    renderer.setZoomRate(1.05f);
    renderer.setBarSpacing(0.5f);
    renderer.setLabelsColor(Color.WHITE);
    renderer.setXLabelsColor(Color.GREEN);
    renderer.setYLabelsColor(0, colors[0]);
    renderer.setYLabelsColor(1, colors[1]);
    renderer.getSeriesRendererAt(0).setDisplayChartValues(true);
    renderer.getSeriesRendererAt(1).setDisplayChartValues(true);
    renderer.setYTitle("Hours", 1);
    renderer.setYAxisAlign(Align.RIGHT, 1);
    renderer.setYLabelsAlign(Align.LEFT, 1);
    renderer.setDisplayChartValues(true);
    renderer.addYTextLabel(20, "Test", 0);
    renderer.addYTextLabel(10, "New Test", 1);
    renderer.setPanEnabled(true, false);
    renderer.setScale(4.0f);
    XYMultipleSeriesDataset dataset = buildDataset(titles, x, values);
    values.clear();
    values.add(new double[] { 4.3, 4.9, 5.9, 8.8, 10.8, 11.9, 13.6, 12.8, 11.4 });

    addXYSeries(dataset, new String[] { "Sunshine hours" }, x, values, 1);

//    Intent intent = ChartFactory.getCubicLineChartIntent(context, dataset, 
renderer, 0.3f,
//        "Average temperature");

    String[] types = new String[] { BarChart.TYPE,BarChart.TYPE,BarChart.TYPE, LineChart.TYPE
             };
        Intent intent = ChartFactory.getCombinedXYChartIntent(context, dataset, renderer, types,
            "Weather parameters");

    return intent;
  }
}

What version of the product binary library are you using?

achartengine 1.0.0 .jar
Please provide any additional information below.

Original issue reported on code.google.com by cmaheshs...@gmail.com on 13 Apr 2012 at 8:07

GoogleCodeExporter commented 9 years ago

Original comment by dandrome...@gmail.com on 10 May 2012 at 10:15