TeeChart for android Area issues

TeeChart for Java (NetBeans, Eclipse, Android Studio, etc)
Post Reply
jesus.navarro
Newbie
Newbie
Posts: 2
Joined: Thu Jan 26, 2012 12:00 am

TeeChart for android Area issues

Post by jesus.navarro » Tue Jan 22, 2013 4:26 pm

Hi, I’m using Tee Chart for Android and I’ve got some troubles using Area Chart.
The first is that the Area chart is only painting the area between the two last points on the chart.
The Second is that the chart does not start in the left side of the layout, there is a weird unused white space before the chart starts. My guess is that the left axis lifts that space but I don’t know how to delete it.

Image

Heare is the code:

Code: Select all

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

import com.steema.teechart.BevelStyle;
import com.steema.teechart.TChart;
import com.steema.teechart.axis.Axes;
import com.steema.teechart.axis.Axis;
import com.steema.teechart.drawing.Color;
import com.steema.teechart.drawing.Point;
import com.steema.teechart.drawing.StringAlignment;
import com.steema.teechart.events.ChartMouseEvent;
import com.steema.teechart.events.ChartMouseListener;
import com.steema.teechart.styles.Area;
import com.steema.teechart.styles.Line;
import com.steema.teechart.styles.PointerStyle;
import com.steema.teechart.styles.Series;
import com.steema.teechart.styles.SeriesMarks;
import com.steema.teechart.styles.SeriesXYPoint;
import com.steema.teechart.styles.Shape;
import com.steema.teechart.styles.VerticalAxis;
import com.steema.teechart.tools.Annotation;
import com.steema.teechart.tools.MarksTip;
import com.steema.teechart.tools.AnnotationPosition;

import android.app.Activity;
import android.content.Context;
import android.graphics.Paint.Align;
import android.os.Bundle;
import android.os.Handler;
import android.util.Log;
import android.view.Display;
import android.view.Gravity;
import android.view.View;
import android.view.WindowManager;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.view.Display;



public class GraficaLineas{
	Context con =  null;
	List<double []>  arraycosas_mes_X =  null;
	List<double []> arraycosas_mes_Y =  null;
	private TChart chart;
	String mes;
	int x11;
	int call;
	Annotation annotation1;
	boolean bandera;
	int bsum = 0;
	Area series;
	TextView numero;
	
	public GraficaLineas(List<double[]> lista_puntitos_x, List<double[]> lista_puntitos_y, Context c, String mes, int call) {
		arraycosas_mes_X = lista_puntitos_x;
		arraycosas_mes_Y = lista_puntitos_y;
		con = c;
		this.mes = mes;
		this.call = call;
	}
	
	public TChart getGrafica(){
		chart = new TChart(con);
		chart.removeAllSeries();
		chart.getAspect().setView3D(false);
		chart.removeAllSeries();
		chart.getLegend().setVisible(false);
		chart.setBackground(Color.WHITE);
		chart.getHeader().setVisible(false);
		chart.getPanel().setBevelOuter(BevelStyle.NONE);
		try{
			series = new Area(chart.getChart());
			AgregarPuntos();
			((Area)chart.getSeries(0)).setColor(Color.fromArgb(197, 208, 220));
			series.getAreaBrush().setVisible(true);
			((Area)chart.getSeries(0)).getLinePen().setWidth(5);
			((Area)chart.getSeries(0)).getLinePen().setColor(Color.fromArgb(196, 207, 219));
			chart.getWalls().setVisible(false);
			chart.getAxes().getBottom().setAutomatic(false);
			chart.getAxes().getBottom().setMaximum(32);
			chart.getAxes().getBottom().setMinimum(0.5);
			chart.getAxes().getBottom().setVisible(false);
			axesStyle(series.getMaxYValue(), series.getMinYValue());
			series.getPointer().setColor(Color.fromArgb(169, 188, 206));
			series.getPointer().getPen().setColor(Color.fromArgb(169, 188, 206));
			series.getPointer().setStyle(PointerStyle.CIRCLE);
			series.getPointer().setHorizSize(8);
			series.getPointer().setVertSize(8);
			series.getPointer().setVisible(true);
			series.getAreaLines().setVisible(false);
			chart.getAxes().getRight().setVisible(true);
			chart.addSeries(series);
			annotation1 = new Annotation(chart.getChart());
			annotation1.setActive(false);
			chart.addChartMouseListener(new ChartMouseListener() {
				public void backgroundClicked(ChartMouseEvent arg0) {
					bandera = false;
					bsum = 0;
					 Point punto = arg0.getPoint();
					 double xx = 0;
					 double yy = 0;
					 int xxt = 0;
					 int yyt = 0;
							 x11 = -1;
							 xx = 0;
							 yy = 0;
							 xxt = 0;
							 yyt = 0;
							 x11 =	series.getPointer().getSeries().clicked(punto.getX(), punto.getY());
							if (x11 != -1){
								SeriesXYPoint pts = new SeriesXYPoint(series, x11);
								xx = pts.getX();
								yy = pts.getY();
							}
					inicia(x11, xx, yy, punto);
					contador();
				}
				@Override
				public void axesClicked(ChartMouseEvent arg0) {	}

				@Override
				public void legendClicked(ChartMouseEvent arg0) {	}

				@Override
				public void titleClicked(ChartMouseEvent arg0) {} 
			});
			 return chart;
		}catch(Exception e){
			Log.e("Excepcion", e + "");
			return null;
		}
    }   
	
	void axesStyle(double tamañom, double tamañm){
		if (call == 1 || call == 3){
			chart.getAxes().getLeft().setAutomatic(false);
			chart.getAxes().getLeft().setStartPosition(0);
			chart.getAxes().getLeft().setIncrement(1);
			chart.getAxes().getLeft().setMaximum(tamañom+1);
			chart.getAxes().getLeft().getAxisPen().setVisible(false);
			chart.getAxes().getLeft().getGrid().setVisible(false);
			chart.getAxes().getLeft().setRelativePosition(100);
			
		}if (call == 2){
			chart.getAxes().getLeft().setAutomatic(false);
			chart.getAxes().getLeft().setMaximum(tamañom + 500);
			if (tamañom > 300){
				chart.getAxes().getLeft().setMinimum(tamañm - 300);
			}else{ chart.getAxes().getLeft().setMinimum(tamañm);}
			chart.getAxes().getLeft().getLabels().setValueFormat("$");
			chart.getAxes().getLeft().getAxisPen().setVisible(false);
			chart.getAxes().getLeft().getGrid().setVisible(false);
			chart.getAxes().getLeft().setRelativePosition(100);
			
		}
	}
	
	void inicia (int x11, double xx, double yy, Point punto){
		if (x11 != -1){
			chart.refreshDrawableState();
		    annotation1.getShape().setCustomPosition(true);
		    annotation1.getShape().getPen().setVisible(false);
		    annotation1.getShape().setColor(Color.fromArgb(240, 240, 240));
		    annotation1.getShape().getShadow().setColor(Color.fromArgb(172, 221, 243));
		    Shape forma = new Shape(chart.getChart());
			if (call == 1 || call == 3){
				annotation1.setText((int) xx + " " + mes + "\n" + (int)yy);
				annotation1.getShape().getFont().setColor(Color.fromArgb(98, 163, 222));
				annotation1.getShape().getFont().setSize(17);
				annotation1.getShape().setLeft(punto.getX());
				annotation1.getShape().setTop(punto.getY()-10);
			}if (call == 2){
				annotation1.setText((int) xx + " " + mes + "\n$" + yy);
				annotation1.getShape().getFont().setColor(Color.fromArgb(98, 163, 222));
				annotation1.getShape().getFont().setSize(17);
				annotation1.getShape().setLeft(punto.getX());
				annotation1.getShape().setTop(punto.getY()-10);
			}
			annotation1.setActive(true);
			chart.refreshControl();
			x11 = -1;
		}
	}
    
    Runnable codigoHilo= new Runnable(){
        @Override
        public void run(){
			annotation1.setActive(false);
			chart.refreshControl();
        }
    };
    final Handler manejador=new Handler();
    protected  void contador(){
        final Thread t = new Thread(){
            public void run(){
            	bandera = true;
            	System.out.println(bsum + " , " + bandera);
                try{
                	while(bandera && (bsum < 4000)){
                		Thread.sleep(1);
                		bsum = bsum + 1;
                	}if (bandera){
                		manejador.post(codigoHilo);
                	}
                } catch (InterruptedException e){
                    e.printStackTrace();
                }
            }
        };
        t.start();
    }
    private void AgregarPuntos(){
    	if (call == 2){
	    	for (int i = 0 ; i < (arraycosas_mes_Y.get(0).length - 1); i++){
	    		if (arraycosas_mes_X.get(0)[i] != arraycosas_mes_X.get(0)[i+1]){
	    			series.add(arraycosas_mes_X.get(0)[i], arraycosas_mes_Y.get(0)[i]);
	    		}
			}
	    	series.add(arraycosas_mes_X.get(0)[arraycosas_mes_Y.get(0).length - 1], arraycosas_mes_Y.get(0)[arraycosas_mes_Y.get(0).length - 1]);
    	}if (call == 1 || call == 3){
    		for (int i = 0 ; i < (arraycosas_mes_Y.get(0).length); i++){
				series.add(arraycosas_mes_X.get(0)[i], arraycosas_mes_Y.get(0)[i]);
			}
    	}
    }
}
I'm using TeeChart Java v1 for Android

I really apreciate your help.

Yeray
Site Admin
Site Admin
Posts: 9613
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: TeeChart for android Area issues

Post by Yeray » Thu Jan 24, 2013 12:16 pm

Hi Jesus,

I see you have hidden the Walls:

Code: Select all

         chart.getWalls().setVisible(false);
If I comment the line above, with this code on my Activity onCreate method, I get the chart below:

Code: Select all

		LinearLayout group = (LinearLayout) findViewById(R.id.chart_layout);

		double[] xvals = {5, 10, 15, 20};
		List<double[]> xvalues = new ArrayList<double[]>();
		xvalues.add(xvals);
		
		double[] yvals = {6000, 8000, 10000, 12000};
		List<double[]> yvalues = new ArrayList<double[]>();
		yvalues.add(yvals);
		
		GraficaLineas grafica = new GraficaLineas(xvalues, yvalues, this, "Enero", 2);
		TChart tChart1 = grafica.getGrafica(); 
		group.addView(tChart1);
walls visible.png
walls visible.png (9.04 KiB) Viewed 15120 times
Then, it seems the space on the left is actually the space for the left axis labels, that you have moved to the right with:

Code: Select all

			chart.getAxes().getLeft().setRelativePosition(100);
But you could use the right axis instead:

Code: Select all

			chart.getSeries(0).setVerticalAxis(VerticalAxis.RIGHT);
And set the right axis instead of the left axis:

Code: Select all

	void axesStyle(double tamañom, double tamañm) {
		if (call == 1 || call == 3) {
			chart.getAxes().getRight().setAutomatic(false);
			chart.getAxes().getRight().setStartPosition(0);
			chart.getAxes().getRight().setIncrement(1);
			chart.getAxes().getRight().setMaximum(tamañom + 1);
			chart.getAxes().getRight().getAxisPen().setVisible(false);
			chart.getAxes().getRight().getGrid().setVisible(false);
			//chart.getAxes().getRight().setRelativePosition(100);
		}
		if (call == 2) {
			chart.getAxes().getRight().setAutomatic(false);
			chart.getAxes().getRight().setMaximum(tamañom + 500);
			if (tamañom > 300) {
				chart.getAxes().getRight().setMinimum(tamañm - 300);
			} else {
				chart.getAxes().getRight().setMinimum(tamañm);
			}
			chart.getAxes().getRight().getLabels().setValueFormat("$");
			chart.getAxes().getRight().getAxisPen().setVisible(false);
			chart.getAxes().getRight().getGrid().setVisible(false);
			//chart.getAxes().getLeft().setRelativePosition(100);
		}
	}
right axis.png
right axis.png (8.4 KiB) Viewed 15103 times
Then, hiding the walls again I get this:
right axis walls hidden.png
right axis walls hidden.png (7.82 KiB) Viewed 15109 times
Is that what you wanted?
You can also try playing with the Panel Margins, setting negative values.
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

jesus.navarro
Newbie
Newbie
Posts: 2
Joined: Thu Jan 26, 2012 12:00 am

Re: TeeChart for android Area issues

Post by jesus.navarro » Fri Jan 25, 2013 5:15 pm

Hi Yeray,

About the Area Brush, I've tried

Code: Select all

chart.getWalls().setVisible(true);
and it's still not working.

I've seen that you inserted a layout inside the class that I've posted, but I'm ussing it ass an object. I have a class A that calls this class, it's something like this:
code:

Code: Select all

RelativeLayout layout1 = (RelativeLayout)vista.findViewById(R.id.layout1);
RelativeLayout layout2 = (RelativeLayout)vista.findViewById(R.id.layout2);
private TChart gv_1 = null;
private TChart gv_2 = null;
gv_1 = new GraficaLineas(x1	, y1, getActivity(), mesg, 2).getGrafica();
gv_2 = new GraficaLineas(x2 , y2, getActivity(), mesg, 1).getGrafica();
layout1.removeAllViews();
layout2.removeAllViews();
layout1.addView(  gv_1);
layout2.addView( gv_2 );
And about the Axis, I've tried setting the right axis, but I need the ticks to be displayed after the labels and setting the right axis the ticks are displayed before the labels. Is there a way to set the order to display ticks and labels int right axis?.

Thanks for your help Yeray.

Yeray
Site Admin
Site Admin
Posts: 9613
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: TeeChart for android Area issues

Post by Yeray » Mon Jan 28, 2013 1:47 pm

jesus.navarro wrote:Hi Yeray,

About the Area Brush, I've tried

Code: Select all

chart.getWalls().setVisible(true);
and it's still not working.
Sorry, I haven't been able to reproduce the problem with the Area Brush. It seems to be correctly drawn for me here with v2012.0808. Is this one the version you are using?
Making the Walls visible was just to notice how the space on the left seems to be the same the axis labels have reserved.

jesus.navarro wrote:And about the Axis, I've tried setting the right axis, but I need the ticks to be displayed after the labels and setting the right axis the ticks are displayed before the labels. Is there a way to set the order to display ticks and labels int right axis?.
I think the easier way to achieve this is to use a custom axis because only the regular axes (left, right, top, bottom) calculate and reserve the space the labels need to be drawn.
To do so, you could create and assign the custom axis before calling your axesStyle function:

Code: Select all

			Axis myAxis = new Axis();
			chart.getAxes().getCustom().add(myAxis);
			series.setCustomVertAxis(myAxis);
			
			axesStyle(series.getMaxYValue(), series.getMinYValue());
And then, the axesStyle function could be slightly different, to configure this custom axis instead of the default left or right one:

Code: Select all

	void axesStyle(double tamañom, double tamañm) {
		Axis myAxis = series.getCustomVertAxis();
		if (call == 1 || call == 3) {
			myAxis.setAutomatic(false);
			myAxis.setStartPosition(0);
			myAxis.setIncrement(1);
			myAxis.setMaximum(tamañom + 1);
			myAxis.getAxisPen().setVisible(false);
			myAxis.getGrid().setVisible(false);
			myAxis.setRelativePosition(100);
		}
		if (call == 2) {
			myAxis.setAutomatic(false);
			myAxis.setMaximum(tamañom + 500);
			if (tamañom > 300) {
				myAxis.setMinimum(tamañm - 300);
			} else {
				myAxis.setMinimum(tamañm);
			}
			myAxis.getLabels().setValueFormat("$");
			myAxis.getAxisPen().setVisible(false);
			myAxis.getGrid().setVisible(false);
			myAxis.setRelativePosition(100);
		}
	}
jesus.navarro wrote:I've seen that you inserted a layout inside the class that I've posted, but I'm ussing it ass an object. I have a class A that calls this class, it's something like this:
code:

Code: Select all

RelativeLayout layout1 = (RelativeLayout)vista.findViewById(R.id.layout1);
RelativeLayout layout2 = (RelativeLayout)vista.findViewById(R.id.layout2);
private TChart gv_1 = null;
private TChart gv_2 = null;
gv_1 = new GraficaLineas(x1	, y1, getActivity(), mesg, 2).getGrafica();
gv_2 = new GraficaLineas(x2 , y2, getActivity(), mesg, 1).getGrafica();
layout1.removeAllViews();
layout2.removeAllViews();
layout1.addView(  gv_1);
layout2.addView( gv_2 );
This doesn't change the result for the particular charts I'm drawing, at least in respect to the issues reported here.

Find below the full code I'm using:

main.xml:

Code: Select all

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <TextView
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content"
        android:text="@string/hello"/>
	<RelativeLayout android:id="@+id/chart_layout1"
	    android:layout_width="fill_parent"
	    android:layout_height="125dp"/>
	
	<RelativeLayout android:id="@+id/chart_layout2"
	    android:layout_width="fill_parent"
	    android:layout_height="125dp"/>
</LinearLayout>
GraficaLineas.java:

Code: Select all

package com.steema.test;

import java.util.List;

import android.content.Context;
import android.os.Handler;
import android.util.Log;
import android.widget.TextView;

import com.steema.teechart.BevelStyle;
import com.steema.teechart.TChart;
import com.steema.teechart.axis.Axis;
import com.steema.teechart.drawing.Color;
import com.steema.teechart.drawing.Point;
import com.steema.teechart.events.ChartMouseAdapter;
import com.steema.teechart.events.ChartMouseEvent;
import com.steema.teechart.styles.Area;
import com.steema.teechart.styles.PointerStyle;
import com.steema.teechart.styles.SeriesXYPoint;
import com.steema.teechart.tools.Annotation;

public class GraficaLineas {
	Context con = null;
	List<double[]> arraycosas_mes_X = null;
	List<double[]> arraycosas_mes_Y = null;
	private TChart chart;
	String mes;
	int x11;
	int call;
	Annotation annotation1;
	boolean bandera;
	int bsum = 0;
	Area series;
	TextView numero;

	public GraficaLineas(List<double[]> lista_puntitos_x, List<double[]> lista_puntitos_y, Context c, String mes, int call) {
		arraycosas_mes_X = lista_puntitos_x;
		arraycosas_mes_Y = lista_puntitos_y;
		con = c;
		this.mes = mes;
		this.call = call;
	}

	public TChart getGrafica() {
		chart = new TChart(con);
		chart.removeAllSeries();
		chart.getAspect().setView3D(false);
		chart.removeAllSeries();
		chart.getLegend().setVisible(false);
		chart.setBackground(Color.WHITE);
		chart.getHeader().setVisible(false);
		chart.getPanel().setBevelOuter(BevelStyle.NONE);
		try {
			series = new Area(chart.getChart());
			AgregarPuntos();
			((Area) chart.getSeries(0)).setColor(Color.fromArgb(197, 208, 220));
			series.getAreaBrush().setVisible(true);
			((Area) chart.getSeries(0)).getLinePen().setWidth(5);
			((Area) chart.getSeries(0)).getLinePen().setColor(Color.fromArgb(196, 207, 219));
			chart.getWalls().setVisible(false);
			chart.getAxes().getBottom().setAutomatic(false);
			chart.getAxes().getBottom().setMaximum(32);
			chart.getAxes().getBottom().setMinimum(0.5);
			chart.getAxes().getBottom().setVisible(false);

			Axis myAxis = new Axis();
			chart.getAxes().getCustom().add(myAxis);
			series.setCustomVertAxis(myAxis);

			axesStyle(series.getMaxYValue(), series.getMinYValue());
			series.getPointer().setColor(Color.fromArgb(169, 188, 206));
			series.getPointer().getPen().setColor(Color.fromArgb(169, 188, 206));
			series.getPointer().setStyle(PointerStyle.CIRCLE);
			series.getPointer().setHorizSize(8);
			series.getPointer().setVertSize(8);
			series.getPointer().setVisible(true);
			series.getAreaLines().setVisible(false);
			chart.addSeries(series);
			annotation1 = new Annotation(chart.getChart());
			annotation1.setActive(false);
			chart.addChartMouseListener(new ChartMouseAdapter() {
				public void backgroundClicked(ChartMouseEvent arg0) {
					bandera = false;
					bsum = 0;
					Point punto = arg0.getPoint();
					double xx = 0;
					double yy = 0;
					x11 = -1;
					xx = 0;
					yy = 0;
					x11 = series.getPointer().getSeries().clicked(punto.getX(), punto.getY());
					if (x11 != -1) {
						SeriesXYPoint pts = new SeriesXYPoint(series, x11);
						xx = pts.getX();
						yy = pts.getY();
					}
					inicia(x11, xx, yy, punto);
					contador();
				}
			});

			// chart.getWalls().setVisible(true);
			return chart;
		} catch (Exception e) {
			Log.e("Excepcion", e + "");
			return null;
		}
	}

	void axesStyle(double tamañom, double tamañm) {
		Axis myAxis = series.getCustomVertAxis();
		if (call == 1 || call == 3) {
			myAxis.setAutomatic(false);
			myAxis.setStartPosition(0);
			myAxis.setIncrement(1);
			myAxis.setMaximum(tamañom + 1);
			myAxis.getAxisPen().setVisible(false);
			myAxis.getGrid().setVisible(false);
			myAxis.setRelativePosition(100);

		}
		if (call == 2) {
			myAxis.setAutomatic(false);
			myAxis.setMaximum(tamañom + 500);
			if (tamañom > 300) {
				myAxis.setMinimum(tamañm - 300);
			} else {
				myAxis.setMinimum(tamañm);
			}
			myAxis.getLabels().setValueFormat("$");
			myAxis.getAxisPen().setVisible(false);
			myAxis.getGrid().setVisible(false);
			myAxis.setRelativePosition(100);
		}
	}

	void inicia(int x11, double xx, double yy, Point punto) {
		if (x11 != -1) {
			chart.refreshDrawableState();
			annotation1.getShape().setCustomPosition(true);
			annotation1.getShape().getPen().setVisible(false);
			annotation1.getShape().setColor(Color.fromArgb(240, 240, 240));
			annotation1.getShape().getShadow().setColor(Color.fromArgb(172, 221, 243));
			if (call == 1 || call == 3) {
				annotation1.setText((int) xx + " " + mes + "\n" + (int) yy);
				annotation1.getShape().getFont().setColor(Color.fromArgb(98, 163, 222));
				annotation1.getShape().getFont().setSize(17);
				annotation1.getShape().setLeft(punto.getX());
				annotation1.getShape().setTop(punto.getY() - 10);
			}
			if (call == 2) {
				annotation1.setText((int) xx + " " + mes + "\n$" + yy);
				annotation1.getShape().getFont().setColor(Color.fromArgb(98, 163, 222));
				annotation1.getShape().getFont().setSize(17);
				annotation1.getShape().setLeft(punto.getX());
				annotation1.getShape().setTop(punto.getY() - 10);
			}
			annotation1.setActive(true);
			chart.refreshControl();
			x11 = -1;
		}
	}

	Runnable codigoHilo = new Runnable() {
		@Override
		public void run() {
			annotation1.setActive(false);
			chart.refreshControl();
		}
	};
	final Handler manejador = new Handler();

	protected void contador() {
		final Thread t = new Thread() {
			public void run() {
				bandera = true;
				System.out.println(bsum + " , " + bandera);
				try {
					while (bandera && (bsum < 4000)) {
						Thread.sleep(1);
						bsum = bsum + 1;
					}
					if (bandera) {
						manejador.post(codigoHilo);
					}
				} catch (InterruptedException e) {
					e.printStackTrace();
				}
			}
		};
		t.start();
	}

	private void AgregarPuntos() {
		if (call == 2) {
			for (int i = 0; i < (arraycosas_mes_Y.get(0).length - 1); i++) {
				if (arraycosas_mes_X.get(0)[i] != arraycosas_mes_X.get(0)[i + 1]) {
					series.add(arraycosas_mes_X.get(0)[i], arraycosas_mes_Y.get(0)[i]);
				}
			}
			series.add(arraycosas_mes_X.get(0)[arraycosas_mes_Y.get(0).length - 1], arraycosas_mes_Y.get(0)[arraycosas_mes_Y.get(0).length - 1]);
		}
		if (call == 1 || call == 3) {
			for (int i = 0; i < (arraycosas_mes_Y.get(0).length); i++) {
				series.add(arraycosas_mes_X.get(0)[i], arraycosas_mes_Y.get(0)[i]);
			}
		}
	}
}
AndroidTestActivity.java:

Code: Select all

package com.steema.test;

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

import android.app.Activity;
import android.os.Bundle;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;

import com.steema.teechart.TChart;

public class AndroidTestActivity extends Activity {

	private TChart tChart1;

	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main);

		RelativeLayout layout1 = (RelativeLayout) findViewById(R.id.chart_layout1);
		RelativeLayout layout2 = (RelativeLayout) findViewById(R.id.chart_layout2);
		TChart gv_1 = null;
		TChart gv_2 = null;

		double[] xvals = { 1, 3, 10, 13 };
		List<double[]> xvalues = new ArrayList<double[]>();
		xvalues.add(xvals);

		double[] yvals1 = { 6000, 8000, 10000, 12000 };
		List<double[]> yvalues1 = new ArrayList<double[]>();
		yvalues1.add(yvals1);

		double[] yvals2 = { 7, 4, 5, 2 };
		List<double[]> yvalues2 = new ArrayList<double[]>();
		yvalues2.add(yvals2);

		String mesg = "Enero";
		gv_1 = new GraficaLineas(xvalues, yvalues1, this, mesg, 2).getGrafica();
		gv_2 = new GraficaLineas(xvalues, yvalues2, this, mesg, 1).getGrafica();
		layout1.removeAllViews();
		layout2.removeAllViews();
		layout1.addView(gv_1);
		layout2.addView(gv_2);
	}
}
device-2013-01-28-144413.png
device-2013-01-28-144413.png (7.96 KiB) Viewed 15036 times
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Post Reply