whitespace COMPANY whitespace SERVICES whitespace PRODUCTS whitespace PURCHASE whitespace SUPPORT whitespace CONTACTS whitespace Home whitespace Contact Us whitespace Site Map whitespace
whitespace
SUPPORT
whitespace
FORUM
whitespace
FAQS
whitespace
SUBSCRIPTION
whitespace
REQUEST ON-LINE
whitespace
whitespace

Technical Support Forum

Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
View
Go to last post Go to first unread
emoney  
#1 Posted : Friday, March 8, 2013 6:47:29 PM(UTC)
emoney
Rank: Newbie

Groups: Registered
Joined: 3/8/2013(UTC)
Posts: 1
Location: Dublin

Hi,

I'd like to use aiChart Control to build a bar/stackedbar chart.

With YAxis is category and XAxis is datetime.

I've tried to changed the code from aiCharts.DateTime sample.
But can not figure out the solution.
And the diagram attached.

Anyone can help?

Code:

	ChartSeries series1 = new ChartSeries("Series 1", ChartTypes.Bar);
		ChartSeries series2 = new ChartSeries("Series 2", ChartTypes.Bar);
		
		ChartPointCollection series1Points = series1.getPoints();
		ChartPointCollection series2Points = series2.getPoints();
		// Getting current time
		Date xDate = GregorianCalendar.getInstance().getTime();
		Random r = new Random();
		for(int i = 0; i < 4; i++)
		{
			xDate.setMonth(i);
			series1Points.addDate(xDate, r.nextDouble());
			series2Points.addDate(xDate, r.nextDouble());
		}
		
		chart.getAreas().add(area);
		chart.getSeries().add(series1);
		chart.getSeries().add(series2);
		series1.setArea(area.getName());
		series2.setArea(area.getName());
		ChartAxis axis = area.getDefaultXAxis();
		axis.setLabelFormat(new SimpleDateFormat("MMM, dd"));
		axis.setValueType(ChartAxis.ValueType.Date);
		axis.setLabelsAdapter(ChartAxis.SERIES_LABELS_ADAPTER);

Edited by user Friday, March 8, 2013 6:49:17 PM(UTC)  | Reason: Not specified

emoney attached the following image(s):
barGraphMockup.jpg (65kb) downloaded 18 time(s).

You cannot view/download attachments. Try to login or register.
Baydalka Volodymyr  
#2 Posted : Wednesday, March 13, 2013 12:46:21 PM(UTC)
Baydalka Volodymyr
Rank: Member

Groups: Registered
Joined: 7/28/2009(UTC)
Posts: 447
Man

Hi,

Check the sample:

Code:
ChartView chartView = new ChartView(this);

ChartArea chartArea = new ChartArea();
ChartSeries series = new ChartSeries(ChartTypes.Bar);
Calendar calendar = Calendar.getInstance();

calendar.clear();

for (int i = 1; i <= 4; i++)
{
	calendar.set(2013, 3, 3 + i);
	
	series.getPoints().addXY(i, calendar.getTimeInMillis()).setAxisLabel("Vehicle" + i);
}

calendar.set(2013, 3, 1);

chartArea.getDefaultYAxis().setLabelsAdapter(ChartAxis.SERIES_LABELS_ADAPTER);
// Y values - contains date
chartArea.getDefaultXAxis().setValueType(ValueType.Date);
// start bars from lower axis value
chartArea.getDefaultXAxis().setOrigin(Double.NEGATIVE_INFINITY);
// setup start value 
chartArea.getDefaultXAxis().getScale().setMinimum((double) calendar.getTimeInMillis());

chartView.getAreas().add(chartArea);
chartView.getSeries().add(series);

setContentView(chartView);


Best regards,
Volodymyr Baydalka
Andriod development and support team
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Company | Services | Practices | Technologies | Career | Contacts | Privacy
© 2005-2017 ArtfulBits. All rights reserved.