chart background + remove grid in Android

TeeChart for Java (NetBeans, Eclipse, Android Studio, etc)
Post Reply
yos
Newbie
Newbie
Posts: 8
Joined: Wed Jan 25, 2012 12:00 am

chart background + remove grid in Android

Post by yos » Wed Jan 25, 2012 2:26 pm

Hi,

i have two questions regarding chart background (or panel background) and removing the grid background in a line chart.

[*]lest's start with the chart background:
i managed to produce two graphs one is a 3D pie chart and the other is a line chart both of them presented in the images below

Image
Image

i am trying to remove the 3d like surface behind the graphs (they are marked in the pie with an arrow and in the chart with the left arrow)
this is the code i wrote for the pie:

Code: Select all

mPie = (RelativeLayout)mRootView.findViewById(R.id.status_disk_pie);
chart = new TChart(mRootView.getContext());
chart.getGraphics3D().getAspect().setView3D(true);
chart.getGraphics3D().getAspect().setChart3DPercent(30);
chart.setClickable(true);
chart.addChartMouseListener(new ChartMouseListener() 
{
	@Override
	public void titleClicked(ChartMouseEvent arg0) {
		
	}
			
	@Override
	public void legendClicked(ChartMouseEvent arg0) {
			
	}
			
	@Override
	public void backgroundClicked(ChartMouseEvent arg0) {
				
	}
			
	@Override
	public void axesClicked(ChartMouseEvent arg0) {

	}
});
		
chart.getPanel().setColor(Color.TRANSPARENT); // background
chart.getPanel().setMarginBottom(1);
chart.getPanel().setMarginLeft(0);
chart.getPanel().setMarginRight(1);
chart.getPanel().setMarginTop(5);
		
chart.getLegend().setVisible(false);
chart.getHeader().setVisible(false);

Series pie = new Pie(chart.getChart());
pie.add(20,Color.green);
pie.add(80,Color.red);
pie.getMarks().setVisible(false); // disabels markers 
chart.addSeries(pie);
mPie.addView(chart);
[*]the second question regards the grid of the line chart as presented in the 2nd image (right arrow)
how do i remove it from the graph ?

Thanks!

keith20mm
Newbie
Newbie
Posts: 6
Joined: Fri Jan 20, 2012 12:00 am

Re: chart background + remove grid in Android

Post by keith20mm » Wed Jan 25, 2012 3:53 pm

As to the grid visibility:

// disable left axis grid
chart.getAxes().getLeft().getGrid().setDefaultVisible(false);

// disable bottom axis grid
chart.getAxes().getBottom().getGrid().setDefaultVisible(false);

// similar function for getTop() and getRight() grids.

// to change grid style, for example:
// import : import com.steema.teechart.drawing.DashStyle;

chart.getAxes().getLeft().getGrid().setStyle(DashStyle.DASHDOT);

yos
Newbie
Newbie
Posts: 8
Joined: Wed Jan 25, 2012 12:00 am

Re: chart background + remove grid in Android

Post by yos » Wed Jan 25, 2012 4:07 pm

thanks,

i managed to remove the grid as you specified. is there any why to make the background transparent ?

any thoughts about the first question ?

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

Re: chart background + remove grid in Android

Post by Yeray » Wed Jan 25, 2012 4:22 pm

Hi,

It's the Bevel. You can set it to BevelStyle.NONE:

Code: Select all

chart.getPanel().setBevelOuter(BevelStyle.NONE);
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

yos
Newbie
Newbie
Posts: 8
Joined: Wed Jan 25, 2012 12:00 am

Re: chart background + remove grid in Android

Post by yos » Wed Jan 25, 2012 4:41 pm

Thanks,

the Bevel works great !

regarding the line chart, i removed the grid, but now i see a white background, is there any way to set it to transparent ?

keith20mm
Newbie
Newbie
Posts: 6
Joined: Fri Jan 20, 2012 12:00 am

Re: chart background + remove grid in Android

Post by keith20mm » Wed Jan 25, 2012 5:42 pm

Regarding transparency of the background, you can use:

chart.getPanel().setTransparent(true);

As an aside, you could also use a range number to vary the 'pen' used to draw the chart parts.

chart.getPanel().setTransparency(50);

..or you may have an image background.

You might also have an imageview in your chart-enclosing layout view... much depends on exactly what effect you are trying to accomplish.

yos
Newbie
Newbie
Posts: 8
Joined: Wed Jan 25, 2012 12:00 am

Re: chart background + remove grid in Android

Post by yos » Wed Jan 25, 2012 6:46 pm

Hi keith20mm,

are you referring question 1 or 2 in your latest post?

is there any way to post the values of each pie slice on the slices ? meaning to in a side legend or outside the pie chart ?

many thanks !

keith20mm
Newbie
Newbie
Posts: 6
Joined: Fri Jan 20, 2012 12:00 am

Re: chart background + remove grid in Android

Post by keith20mm » Wed Jan 25, 2012 9:17 pm

In your code example above, you have:

chart.getLegend().setVisible(false);

This disabled drawing of the legend.

Change it to this:
chart.getLegend().setVisible(true);

and the legend will show the amounts for each slice.

In the TChart Android demo, if you select a Pie Series from the Series list, you'll see a sample legend near the plot bottom.

yos
Newbie
Newbie
Posts: 8
Joined: Wed Jan 25, 2012 12:00 am

Re: chart background + remove grid in Android

Post by yos » Thu Jan 26, 2012 8:23 am

Hi,

i had grammar problem with my previous post (my bad), what i ment was :

is there any way to post the values of each pie slice ON the slices ? meaning NOT in a side legend or outside the pie chart ?

many thanks !

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

Re: chart background + remove grid in Android

Post by Yeray » Thu Jan 26, 2012 11:37 am

Hi yos,

You could set a negative arrow length, and hide its pen:

Code: Select all

		pie1.getMarks().setArrowLength(-80);
		pie1.getMarks().getArrow().setVisible(false);
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

yos
Newbie
Newbie
Posts: 8
Joined: Wed Jan 25, 2012 12:00 am

Re: chart background + remove grid in Android

Post by yos » Sun Jan 29, 2012 7:28 am

Hi Yeray,

your code works great, one thing though, changing the arrow size changes the scale of my pie chart.
any solution ?

Thanks

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

Re: chart background + remove grid in Android

Post by Yeray » Mon Jan 30, 2012 11:29 am

Hi,

Note that the Pie is redimensioned in order to fit the marks, so changing the marks arrow length changes it.
You could try forcing a ChartRect in a similar way than in the example at "All Features\Welcome !\Chart styles\Standard\Pie\Multiple Pies". You can find this and other examples in the SWT/Swing features demo program included with the evaluation (with complete Java version at the moment, not just the TeeChart Java for Android version).
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