I'm using AChartEngine to display averages across several days (2 months if possible). I'd like to provide a comparison between one individual and a group. At this point, I'm working on how to provide dates across the x-axis (ie, 12/15/2011 or Dec. 11, 2011 or even 12/15, Dec. 15).
I'm not sure how to do this in AchartEngine; the documentation is a little hard for me to follow without pictures (sorry). I'd like something like this: Using AChartEngine library for graphs, not able to get value for diffrent x-axis value
Here's my code:
private void setupHistoryChart() {
XYMultipleSeriesRenderer renderer = getBarDemoRenderer();
setChartSettings(renderer);
Intent intent = ChartFactory.getBarChartIntent(this, getBarDemoDataset(), renderer, Type.DEFAULT);
startActivity(intent);
}
public XYMultipleSeriesRenderer getBarDemoRenderer() {
XYMultipleSeriesRenderer renderer = new XYMultipleSeriesRenderer();
renderer.setAxisTitleTextSize(15);
renderer.setChartTitleTextSize(18);
renderer.setLabelsTextSize(12);
renderer.setLegendTextSize(15);
renderer.setMargins(new int[] {20, 30, 15, 0});
SimpleSeriesRenderer r = new SimpleSeriesRenderer();
r.setColor(Color.BLUE);
renderer.addSeriesRenderer(r);
return renderer;
}
private void setChartSettings(XYMultipleSeriesRenderer renderer) {
renderer.setChartTitle("History");
renderer.setChartTitleTextSize((float) 14.0);
renderer.setXTitle("Day");
renderer.setXLabelsAlign(Align.LEFT);
renderer.setYLabelsAlign(Align.LEFT);
renderer.setBarSpacing(0.5);
renderer.setZoomEnabled(true);
renderer.setZoomRate(0.2f);
renderer.setYTitle("Unit)");
renderer.setXAxisMin(1.0);
if(AppStatus.mDayMap.size() == 0){
renderer.setXAxisMax(3.0);
renderer.setYAxisMax(10.0);
}else{
renderer.setXAxisMax(AppStatus.mDayMap.size());
// Get the max Integer out of myMap
Map.Entry<String, Integer> maxEntry = null;
for (Map.Entry<String, Integer> entry : AppStatus.mDayMap.entrySet())
{
if (maxEntry == null || entry.getValue().compareTo(maxEntry.getValue()) > 0)
{
maxEntry = entry;
}
}
renderer.setYAxisMax(maxEntry.getValue()/1000 + maxEntry.getValue()/1000);
}
renderer.setYAxisMin(0);
}
private XYMultipleSeriesDataset getBarDemoDataset() {
XYMultipleSeriesDataset dataset = new XYMultipleSeriesDataset();
HashMap<String, Integer> myMap = AppStatus.mDayMap;
CategorySeries series = new CategorySeries ("Your History " + 1);
try{
if(AppStatus.mDayMap.size() == 0){
series.add(3.0);
series.add(10.0);
dataset.addSeries(series.toXYSeries());
}else{
Log.v(LOG_TAG, "Size of Map = " + myMap.size());
float sum = (float) 0.0;
if(myMap.size() > 0){
Iterator it = myMap.entrySet().iterator();
float j= (float)0.0;
for (int i = 0; i < 1 /*2*/; i++) {
//CategorySeries series = new CategorySeries("Your History " + (i + 1));
while(it.hasNext()){
Map.Entry pairs = (Map.Entry)it.next();
sum = sum + (float) (1.0 + j);
series.add((((Integer) pairs.getValue()).doubleValue())/1000);
}
dataset.addSeries(series.toXYSeries());
}
}
}
}catch(IllegalArgumentException e){
Log.e(LOG_TAG, "IllegalArgumentException " + e.toString());
series.add(3.0);
series.add(10.0);
dataset.addSeries(series.toXYSeries());
}
return dataset;
}
You can set custom text for the X axis labels:
renderer.addXTextLabel(x, text);
renderer.setXLabels(0);
In order to have multiple color bars in the bar chart, you will have to add multiple series.
There are some instructions here on how to download and run the demo application which includes a lot of good code to demonstrate the AChartEngine usage.
Related
I have a problem with my chart using achartengine. I set data for dataset from my sqlite db, I can show it successfully on the chart but the bar width is to narrow. Here are my GenerateEngine class to generate bar from sqlite db.
public class GenerateChart {
private ExpensesDataSource datasource;
private SpinnerValues spinnerValues = new SpinnerValues();
private SimpleDateFormat monthFormat, yearFormat;
String month, year;
List<String> values;
XYSeries series;
public XYMultipleSeriesDataset getExpensesBarDataset(Context context) {
datasource = new ExpensesDataSource(context);
monthFormat = new SimpleDateFormat("MM");
month = monthFormat.format(new Date());
yearFormat = new SimpleDateFormat("yyyy");
year = yearFormat.format(new Date());
datasource.openToRead();
values = datasource.GetTotalEachCategory(month, year);
datasource.close();
XYMultipleSeriesDataset dataset = new XYMultipleSeriesDataset();
XYSeries series;
for(int i = 0; i < spinnerValues.categoryText.length; i++) {
series = new XYSeries(spinnerValues.categoryText[i]);
series.add(i, Double.parseDouble(values.get(i)));
dataset.addSeries(series);
}
return dataset;
}
public XYMultipleSeriesRenderer getExpensesBarRenderer() {
XYMultipleSeriesRenderer renderer = new XYMultipleSeriesRenderer();
renderer.setAxisTitleTextSize(16);
renderer.setChartTitleTextSize(20);
renderer.setLabelsTextSize(15);
renderer.setLegendTextSize(15);
renderer.setMargins(new int[] { 30, 40, 15, 0 });
XYSeriesRenderer r;
for(int i = 0; i < spinnerValues.categoryColor.length; i++) {
r = new XYSeriesRenderer();
r.setColor(Color.parseColor(spinnerValues.categoryColor[i]));
r.setLineWidth(20);
r.setFillPoints(true);
r.setDisplayChartValues(true);
renderer.addSeriesRenderer(r);
}
return renderer;
}
public void myChartSettings(XYMultipleSeriesRenderer renderer, String month, String year) {
renderer.setChartTitle("Pratinjau Grafik Pengeluaran Bulan " + month + " Tahun " + year);
renderer.setXAxisMin(-10);
renderer.setXAxisMax(10);
renderer.setYAxisMin(0);
renderer.setYAxisMax(500000);
renderer.setYLabelsAlign(Paint.Align.RIGHT);
renderer.setBarSpacing(.1);
renderer.setXTitle("Kategori");
renderer.setYTitle("Total Pengeluaran");
renderer.setShowGrid(true);
renderer.setGridColor(Color.GRAY);
renderer.setZoomButtonsVisible(true);
renderer.setXLabels(0); // sets the number of integer labels to appear
}}
Here is what I got from my class.
I want to add the width of the bar so it will proper. I will appreciate any help, thank you.
setBarWidth api is used for XYMultipleSeriesRenderer
Refer this Api -->API
So in ur code u need to change this :
Inside getExpensesBarRenderer() Api
renderer.setBarWidth()
I am trying to display a graph with the data in the sqlitedatabase using AChartEngine library. I am having two records in database. BarChart graph displayed when there is one record. But with two records of data, it says, "Dataset and renderer should be not null and should have the same number of series". I dont understand this.
My code is,
Button ReportGraph = (Button) findViewById(R.id.ReportGraph);
ReportGraph.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
GraphicalView GraphChartView = ChartFactory.getBarChartView(
getApplicationContext(), getWaterElectricityReading(),
getDemoRenderer(), Type.DEFAULT);
// Intent intent=ChartFactory.getLineChartIntent(this,
// getDemoDataset(), getDemoRenderer());
// startActivity(intent);
if (GraphChartView != null) {
GraphChartView.repaint();
}
relChartView.addView(GraphChartView);
mainLayout.setVisibility(View.GONE);
relChartView.setVisibility(View.VISIBLE);
}
});
private XYMultipleSeriesDataset getWaterElectricityReading() {
XYMultipleSeriesDataset dataset = new XYMultipleSeriesDataset();
SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-mm-dd", Locale.US);
SimpleDateFormat df2 = new SimpleDateFormat("MMM dd yyyy");
Date StartDate;
Date EndDate;
String Pastdateformat = "";
String CurrentDateFormat = "";
SQLiteDatabase DB = Context
.openOrCreateDatabase("WaterElectricityReadingDataBase.db",
MODE_WORLD_READABLE, null);
Cursor c = DB
.rawQuery(
"select ReadingValue,strftime('%m/%d/%Y',StartDateTime) StartDateTime,strftime('%m/%d/%Y',EndDateTime) EndDateTime from WaterElectricity order by StartDateTime desc ",
null);
int rowCount = c.getCount();
if (c != null) {
if (rowCount > 0) {
if (c.moveToFirst()) {
do {
String ReadingValue = c.getString(c
.getColumnIndex("ReadingValue"));
String PastDate = c.getString(c
.getColumnIndex("StartDateTime"));
String CurrentDate = c.getString(c
.getColumnIndex("EndDateTime"));
try {
StartDate = df2.parse(PastDate);
Pastdateformat = sdf1.format(StartDate);
EndDate = df2.parse(CurrentDate);
CurrentDateFormat = sdf1.format(EndDate);
} catch (Exception e) {
}
XYSeries series = new XYSeries(
"WaterElectricityReading");
double ReadingVal = Double.parseDouble(ReadingValue);
series.add(rowCount, ReadingVal);
XYMultipleSeriesRenderer render = new XYMultipleSeriesRenderer();
dataset.addSeries(series);
rowCount++;
} while (c.moveToNext());
}
}
}
return dataset;
}
private XYMultipleSeriesRenderer getDemoRenderer() {
XYMultipleSeriesRenderer renderer = new XYMultipleSeriesRenderer();
renderer.setAxisTitleTextSize(12);
renderer.setChartTitleTextSize(12);
renderer.setLabelsTextSize(15);
renderer.setLegendTextSize(15);
renderer.setPointSize(5f);
renderer.setMargins(new int[] { 20, 30, 15, 0 });
XYSeriesRenderer r = new XYSeriesRenderer();
r.setColor(Color.GREEN);
r.setPointStyle(PointStyle.DIAMOND);
r.setFillBelowLine(false);
r.setFillPoints(true);
renderer.addSeriesRenderer(r);
setChartSettings(renderer);
return renderer;
}
private void setChartSettings(XYMultipleSeriesRenderer renderer) {
renderer.setChartTitle("Chart demo");
renderer.setXTitle("x values");
renderer.setYTitle("y values");
renderer.setApplyBackgroundColor(false);
renderer.setRange(new double[] { 0, 6, -70, 40 });
renderer.setFitLegend(false);
renderer.setAxesColor(Color.BLACK);
renderer.setShowGrid(true);
renderer.setXAxisMin(0);
renderer.setXAxisMax(10.5);
renderer.setYAxisMin(0);
renderer.setZoomEnabled(false);
renderer.setYAxisMax(1000);
}
For two records, I want two bars to be displayed.
Can anyone please point out the Mistake.
Any Help will be appreciated!!
Thanks.
Your chart should be built using one single XYMultipleSeriesDataset and one single XYMultipleSeriesRenderer.
The XYMultipleSeriesDataset should contain as many XYSeries as there are XYSeriesRenderer in XYMultipleSeriesRenderer.
In your code you are creating an XYSeries for each record, which is probably wrong. The data should be in the same series unless you have a good reason not to do that. However, if you add multiple XYSeries then you will need one XYSeriesRenderer for each XYSeries.
i am drawing a bar chart and pie chart to represent the various application names in it using the achartengine library.
When i instantiate CategorySeries object it requires a series title as :
CategorySeries series = new CategorySeries("title") //IN BAR CHART
CategorySeries series = new CategorySeries("title") //IN PIE CHART
Unlike Pie chart the applications name does not get inflated at the bottom of the bar chart
say, in case of pie chart its as follows :
(1) application 1
(2) application 2
(3) application ... up to
(10) application 10.
But its not showing in case of bar char but instead its showing as :
(1) NUMBER OF APPLICATIONS ---->>> (This is the series title i had
passed in as the parameter while
instantiating the object of CategorySeries)
PLEASE SUGGEST ME TO SHOW THE KEY OF BAR CHART ASWELL,I HAVE ATTACHED A CODE SNIPPET BELOW
if (c.getCount() > 0) {
if (! mPieChart) {
series = new CategorySeries("NUMBER OF APPLICATIONS");
getActivity().startManagingCursor(c);
c.moveToPosition(-1);
//series.clear();
while (c.moveToNext()) {
recievedBytes = c.getLong(ApplicationDataCounterDao.CONTENT_RECEIVED_COLUMN);
sentBytes = c.getLong(ApplicationDataCounterDao.CONTENT_SENT_COLUMN);
totalBytes = (recievedBytes + sentBytes) / (1024 * 1024);
if (totalBytes > 0) {
applicationInfo
.add(new ApplicationDataUsage(
c.getString(ApplicationDataCounterDao.CONTENT_APPLICATION_NAME_COLUMN),
Double.toString(totalBytes)));
}
}
int size = applicationInfo.size();
for (int i = 0; i < size; ++i) {
Log.v("BAR CHART", "data added are " + applicationInfo.get(i).mApplicationName);
double value = Double.parseDouble(applicationInfo
.get(i).mDataUsage);
series.add("BAR", value);
}
XYMultipleSeriesDataset dataset = new XYMultipleSeriesDataset();
dataset.addSeries(series.toXYSeries());
XYSeriesRenderer renderer = new XYSeriesRenderer();
renderer.setDisplayChartValues(true);
renderer.setChartValuesSpacing((float) 0.5);
renderer.setColor(Color.CYAN);
XYMultipleSeriesRenderer mRenderer = new XYMultipleSeriesRenderer();
mRenderer.setBarSpacing(0.5);
mRenderer.getBarSpacing();
mRenderer.setXTitle("Application Number");
mRenderer.setYTitle("Data Usage");
mRenderer.setAxesColor(Color.GREEN);
mRenderer.setZoomButtonsVisible(true);
mRenderer.setInScroll(true);
mRenderer.setLabelsColor(Color.RED);
mRenderer.addSeriesRenderer(renderer);
if (mChartViewBar == null) {
Log.v(LOG_TAG, "chart view is null");
mChartViewBar = ChartFactory
.getBarChartView(getActivity(), dataset,
mRenderer, Type.DEFAULT);
mRenderer.setClickEnabled(true);
mRenderer.setSelectableBuffer(10);
mChartViewBar
.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
SeriesSelection seriesSelection = mChartViewBar
.getCurrentSeriesAndPoint();
CategorySeries series22 =new CategorySeries("333");
mChartViewBar.repaint();
if (seriesSelection == null) {
Toast.makeText(
getActivity(),
"No chart element was clicked",
Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(
getActivity(),
"APPLICATION NAME : "
+ series22.getTitle()
+ 1
+ " was clicked"
+ " DATA USAGE : "
+ seriesSelection
.getXValue(),
Toast.LENGTH_SHORT).show();
}
}
});
mChartLayout.removeAllViews();
mChartLayout.addView(mChartViewBar, new LayoutParams(
LayoutParams.FILL_PARENT,
LayoutParams.FILL_PARENT));
} else {
mChartLayout.removeAllViews();
mChartLayout.addView(mChartViewBar, new LayoutParams(
LayoutParams.FILL_PARENT,
LayoutParams.FILL_PARENT));
mChartViewBar.repaint();
}
} else if (mPieChart) {
CategorySeries seriesPie = new CategorySeries("Pie Graph");
getActivity().startManagingCursor(c);
c.moveToPosition(-1);
while (c.moveToNext()) {
long recievedBytes = c .getLong(ApplicationDataCounterDao.CONTENT_RECEIVED_COLUMN);
Long sentBytes = c.getLong(ApplicationDataCounterDao.CONTENT_SENT_COLUMN);
totalBytes = (recievedBytes + sentBytes)
/ (1024 * 1024);
if (totalBytes > 0) {
applicationInfo
.add(new ApplicationDataUsage(
c.getString(ApplicationDataCounterDao.CONTENT_APPLICATION_NAME_COLUMN),
Double.toString(totalBytes)));
}
}
int size = applicationInfo.size();
for (ApplicationDataUsage data_value : applicationInfo) {
Log.v("PIE CHART", "data added are " + data_value.mApplicationName);
double dataUsage = Double
.parseDouble(data_value.mDataUsage);
seriesPie.add(data_value.mApplicationName, dataUsage);
}
for (int i = 0; i < size; ++i) {
prepareColors();
}
DefaultRenderer renderer = new DefaultRenderer();
for (int fillColor : colorList) {
// Log.d("1111111111",
// "FILL COLOUR TILL SIZE OF COLORLIST");
SimpleSeriesRenderer r = new SimpleSeriesRenderer();
r.setColor(fillColor);
renderer.addSeriesRenderer(r);
}
renderer.setInScroll(true);
renderer.setChartTitle("APPLICATION WISE PIE CHART");
renderer.setChartTitleTextSize(20);
renderer.setApplyBackgroundColor(true);
renderer.setBackgroundColor(Color.BLACK);
renderer.setZoomButtonsVisible(true);
if (mChartViewPie == null) {
Log.v(LOG_TAG, "chat view is null");
// series.clear();
mChartViewPie = ChartFactory.getPieChartView(
getActivity(), seriesPie, renderer);
renderer.setClickEnabled(true);
renderer.setSelectableBuffer(10);
mChartViewPie
.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
SeriesSelection seriesSelection = mChartViewPie
.getCurrentSeriesAndPoint();
mChartViewPie.repaint();
if (seriesSelection == null) {
ToastHelper.showToastMessage(
"No item was Clicked",
getActivity());
} else {
ToastHelper.showToastMessage(
"Application number "
+ seriesSelection
.getPointIndex()
+ " was clicked and it's Data Usage is "
+ seriesSelection
.getValue(),
getActivity());
}
}
});
/*if (mChartViewBar != null) {
mChartLayout.removeView(mChartViewBar);
}
if (mChartViewPie != null) {
mChartLayout.removeView(mChartViewPie);
}*/
mChartLayout.addView(mChartViewPie, new LayoutParams(
LayoutParams.FILL_PARENT,
LayoutParams.FILL_PARENT));
} else {
/* if (mChartViewBar != null) {
mChartLayout.removeView(mChartViewBar);
}
if (mChartViewPie != null) {
mChartLayout.removeView(mChartViewPie);
}*/
mChartLayout.removeAllViews();
mChartLayout.addView(mChartViewPie, new LayoutParams(
LayoutParams.FILL_PARENT,
LayoutParams.FILL_PARENT));
mChartViewPie.repaint();
}
}
You are confusing the legend with the X axis labels. The BarChart is an XYChart which means it is getting both legend and x axis labels. The PieChart is not an XYChart, so it is not getting X axis and Y axis.
The series titles go to the legend, as you mentioned.
In the X axis the series values indexes go by default. However, you can hide the default labels and add your own custom ones:
renderer.setXLabels(0);
renderer.addXTextLabel(1, "label);
renderer.addXTextLabel(2, "label);
...
Can u please help me in creating a simple bar chart (for android) where the values are got from sqlite database. for eg consider the following table
year Units Sold
2001 2000
2002 2100
2003 1900
I need to create a bar graph with x-axis as year and y-axis as units sold . Can u Plz consider this as a request . I dont know how to import data from database .
first you have to fetch the values from the data base and stored into array with corresponding data type . Do like this.....
List<int[]> initial;
int[] my_year;
int[] my_units_sold;
public void onCreate()
{
int Column1 = net_db_cur.getColumnIndex("Year");
int Column2 = net_db_cur.getColumnIndex("Units Sold");
cur = sampleDB.rawQuery("SELECT * FROM " + Table_Name , null);
my_year = new int[columncount];
my_units_sold = new int[columncount];
if (cur.moveToFirst())
{
for (int i = 0; i < columncount; i++)
{
my_year [i] = net_db_cur.getInt(Column1);
my_units_sold[i] = net_db_cur.getInt(Column2);
cur.moveToNext();
}
}
initial = new ArrayList<int[]>();
initial1.add(my_year);
initial1.add(my_units_sold);
ll.addView(createBarChart(initial ,Color.BLUE,10,0,14,2000000,20000000,1,x_axis_labels1,x_axis_labels2,y_axis_labels1, y_axis_net_labels2,Color.parseColor("#ffffff")));
}
public View createBarChart(int[] values,int[] colors,int lable_text_size,int xMin,int xMax,int yMin,int yMax,double bar_space,double[] x_axis_lables1,String[] x_axis_lables2,double[] y_axis_lables1,String[] y_axis_lables2, int lable_color)
{
XYMultipleSeriesRenderer mrenderer = new XYMultipleSeriesRenderer();
XYMultipleSeriesDataset dataset = new XYMultipleSeriesDataset();
/*for (int i = 0; i <values.length; i++)
{*/
CategorySeries series = new CategorySeries("");
/*double[] v = values.get(i);
int seriesLength = v.length;*/
for (int k = 0; k < values.length; k++)
{
series.add(values[k]);
}
dataset.addSeries(series.toXYSeries());
//}
//mrenderer.setMargins(new int[] { 10, 65, 10, 15 });
int color_length = colors.length;
for (int i = 0; i < color_length; i++)
{
SimpleSeriesRenderer r = new SimpleSeriesRenderer();
r.setColor(colors[i]);
r.setChartValuesSpacing(15);
mrenderer.addSeriesRenderer(r);
}
mrenderer.setOrientation(Orientation.HORIZONTAL);
mrenderer.setInScroll(false);
mrenderer.setGridColor(Color.BLACK);
mrenderer.setYLabelsAlign(Align.RIGHT);
mrenderer.setPanEnabled(false, false);
mrenderer.setZoomEnabled(false, false);
mrenderer.setBarSpacing(bar_space);
mrenderer.setLabelsTextSize(lable_text_size);
mrenderer.setAxesColor(Color.BLACK);
mrenderer.setXAxisMin(xMin);
mrenderer.setXAxisMax(xMax);
for(int i=0;i<x_axis_lables2.length;i++)
{
mrenderer.addXTextLabel(x_axis_lables1[i],x_axis_lables2[i]);
}
mrenderer.setYAxisMin(yMin);
mrenderer.setYAxisMax(yMax);
for(int j=0;j<y_axis_lables1.length;j++)
{
mrenderer.addYTextLabel(y_axis_lables1[j],y_axis_lables2[j]);
}
mrenderer.setLabelsColor(lable_color);
return (ChartFactory.getBarChartView(Income.this, dataset, mrenderer, Type.DEFAULT));
}
You will get the bar chart for with data base values. All the best.
I've tried to use achart engine but the documentation is somewhat unclear. I've also tried looking through the examples.
Could someone explain how to increase the thickness of the lines in the bar graph that's attached? Also, I would like to separate each bar into it's own series but I haven't had luck doing so (my code is below the image). I've been working on this issue for a really long time!
public XYMultipleSeriesRenderer getBarDemoRenderer() {
Log.d(LOG_TAG, "Entering getBarDemoRenderer");
XYMultipleSeriesRenderer renderer = new XYMultipleSeriesRenderer();
renderer.setAxisTitleTextSize(18);
renderer.setChartTitleTextSize(20);
renderer.setLabelsTextSize(18);
renderer.setLegendTextSize(14);
renderer.setMargins(new int[] {20, 30, 15, 0});
int[] color = {Color.RED, Color.CYAN,Color.YELLOW, Color.LTGRAY,Color.MAGENTA, Color.GREEN, Color.WHITE};
for(int i=0; i<7; i++){
SimpleSeriesRenderer r = new SimpleSeriesRenderer();
r.setColor(color[i]);
renderer.addSeriesRenderer(r);
}
int renderCount = renderer.getSeriesRendererCount();
Log.d(LOG_TAG, "Renderer series count = " + renderCount);
return renderer;
}
private XYMultipleSeriesDataset getApplianceDataset() {
XYMultipleSeriesDataset dataset = new XYMultipleSeriesDataset();
try{
CategorySeries series = null;
for (Map.Entry<String,Float> entry : list.entrySet()) {
String key = entry.getKey();
series = new CategorySeries (key);
String b=String.valueOf(entry.getValue());
double value=Double.valueOf(b);
series.add(value);
dataset.addSeries(series.toXYSeries());
}
}catch(IllegalArgumentException e){
Log.e(LOG_TAG, "IllegalArgumentException " + e.toString());
Toast.makeText(this, "Unable to show chart", Toast.LENGTH_LONG).show();
}
int dataSeriesCount = dataset.getSeriesCount();
return dataset;
}
private void setChartSettings(XYMultipleSeriesRenderer renderer) {
renderer.setChartTitle("Test Bar Chart");
renderer.setChartTitleTextSize(20);
renderer.setXTitle("Appliance");
renderer.setYTitle("Watt Hours (wh)");
renderer.setXAxisMax(3);
renderer.setXAxisMin(0.0);
renderer.setYAxisMax(1800);
renderer.setYAxisMin(0);
}
in setChartSettings give
renderer.setBarSpacing(1.0f);
renderer.setMargins(new int[] {10, 10, 10, 0});