Reputation: 4337
I am working on an application that uses the achartengine library to plot a graph. The values I will have on the X axis will be of format yyyy-MM-dd hh:mm:ss and on the y axis I will have integer values. I am having trouble getting the labels set for the Y and X axis. I would like the Y axis coordinate at the origin to be 0. Here is a sample data set:
X axis values: 2013-07-09 12:34:32, 2013-07-11 10:34:32, 2013-07-11 12:34:31, 2013-07-12 12:34:32
Y Axis Values: 40, 50, 60, 35
I am obtaining the Date object by calling new SimpleDateFormat("yyyy-MM-dd hh:mm:ss").parse(date)
date
is a string in the format yyyy-MM-dd hh:mm:ss
On executing this code below I am not getting the Y coordinate of origin as 0 and also the values of the X axis labels are not in the Date format yyyy-mm-dd hh:mm:ss
. Could someone help to display it in that format? If that is not possible how can I atleast display it in a format such as Jan 1st 2013
or 01-01-2013
Here is my code:
TimeSeries series = new TimeSeries("Line1");
for( int i = 0; i < x.length; i++)
{
//x[i] represents the date object and y[i] represents the integer
series.add(x[i], y[i]);
}
XYMultipleSeriesDataset dataset = new XYMultipleSeriesDataset();
dataset.addSeries(series);
XYMultipleSeriesRenderer mRenderer = new XYMultipleSeriesRenderer(); // Holds a collection of XYSeriesRenderer and customizes the graph
XYSeriesRenderer renderer = new XYSeriesRenderer();
mRenderer.addSeriesRenderer(renderer);
// Customization line 1
renderer.setColor(Color.BLACK);
renderer.setPointStyle(PointStyle.SQUARE);
renderer.setFillPoints(true);
Intent intent = ChartFactory.getLineChartIntent(context, dataset, mRenderer, "Line Graph Title");
return intent;
Upvotes: 2
Views: 1052
Reputation: 32391
You are using a TimeSeries
, so you probably want to build a time chart. So instead of ChartFactory.getLineChartIntent()
you would like to use ChartFactory.getTimeChartIntent()
.
Upvotes: 2