Stacked Bar Chart in android

TeeChart for Java (NetBeans, Eclipse, Android Studio, etc)
Post Reply
Indus Systems
Newbie
Newbie
Posts: 9
Joined: Wed Nov 09, 2011 12:00 am

Stacked Bar Chart in android

Post by Indus Systems » Tue Jan 24, 2012 10:01 am

Hello,
Is it possible to show a bar chart like in attached image?

Regards
Shibu
Indus Systems
Attachments
chart.png
chart.png (5.65 KiB) Viewed 3295 times

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

Re: Stacked Bar Chart in android

Post by Yeray » Tue Jan 24, 2012 11:47 am

Hi Shibu,

The following code draws a chart very similar to the chart in your picture for me here.
There was actually a problem with the marks when they are set to be drawn in the center for stacked bars (TJ71015973). I've just fixed it for the next versions.

Code: Select all

		tChart1.getAspect().setView3D(false);
		
		tChart1.getPanel().setColor(Color.black);
		tChart1.getWalls().setVisible(false);
		tChart1.getAxes().getLeft().getLabels().getFont().setColor(Color.white);
		tChart1.getAxes().getBottom().getLabels().getFont().setColor(Color.white);
		tChart1.getHeader().getFont().setColor(Color.white);
		tChart1.getHeader().getFont().setSize(15);
		tChart1.getHeader().setText("Dallas | Building 1 | Floor 1");
		tChart1.getHeader().setAlignment(StringAlignment.NEAR);
		tChart1.getLegend().setAlignment(LegendAlignment.BOTTOM);
		tChart1.getLegend().getFont().setColor(Color.white);
		tChart1.getLegend().setTransparent(true);
		tChart1.getAxes().getLeft().setIncrement(50);
		tChart1.getAxes().getLeft().setMinMax(0, 350);
		tChart1.getAxes().getBottom().getGrid().setVisible(false);
		
		for (int i=0; i<2; i++) {
			Bar bar = new Bar(tChart1.getChart());
			bar.setMultiBar(MultiBars.STACKED);
			bar.setMarksOnBar(true);
			bar.setMarksLocation(MarksLocation.Center);
			bar.getMarks().setStyle(MarksStyle.VALUE);
			bar.getMarks().setTransparent(true);
			bar.getMarks().getFont().setColor(Color.white);
			bar.getMarks().getFont().setSize(13);
		}
		
		Bar bar1 = (Bar)(tChart1.getSeries(0));
		bar1.setTitle("Occupied");
		bar1.add(250, "Administration");
		bar1.add(145, "Human Resource");
		bar1.add(60, "Finance");
		bar1.add(275, "Support");
		
		Bar bar2 = (Bar)(tChart1.getSeries(1));
		bar2.setTitle("Vacant");
		bar2.setColor(Color.fromArgb(220,80,80));
		bar2.add(50);
		bar2.add(10);
		bar2.add(20);
		bar2.add(25);
Bars.png
Bars.png (20.35 KiB) Viewed 3250 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

Indus Systems
Newbie
Newbie
Posts: 9
Joined: Wed Nov 09, 2011 12:00 am

Re: Stacked Bar Chart in android

Post by Indus Systems » Wed Jan 25, 2012 4:58 am

Hello, Yeray Alonso

Thank you for your support

Shibu
Indus Systems Inc

Post Reply