This question is locked. New answers and comments are not allowed.
Hello again.
I decided to replicate line for line the example provided here https://www.youtube.com/watch?v=JStf9gekJCM so as to see if i could get a working example.
A number of things happened.
1. in the video he uses code like RadCartesianChartView chartView = new RadCartesianChartView(this.getBaseContext()); replicating this resulted in an error and the program would not run. I had to use just "this" instead of this.getBaseContext()
2. The example does not run unless you move chartView.getSeries().add(lineSeries); as the last line in the code. placing it where it is shown in the video results in the example crashing. Not sure whether its an issue with my version.
3. When the example runs, it shows the graph but within the graph there are 4 lines stating a)NoHorizontalAxis, b) NoVerticalAxis , c)NoSeries and d) NoData. This is clearly not true since it is displaying the graph. I've attached a screenshot along with the code i'm using.
I'm using Android Studio (Beta) 0.8.1 and appcompat ver 7.19 along with corresponding support ActionBar
Unfortunately I'm unable to upload the screenshot even though its only 97kb. The uploader complains...not sure why.
-----code----
---Gradle Dependencies
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:19.1.0'
compile 'com.android.support:support-v4:18.0.+'
compile files('libs/socialauth-4.3.jar')
compile files('libs/bugsense-3.5.jar')
compile files('libs/httpmime-4.2.5.jar')
compile files('libs/libGoogleAnalyticsServices.jar')
compile files('libs/socialauth-4.3.jar')
compile (name:'Common-2014.2.0618-trialRelease', ext:'aar')
compile (name:'Primitives-2014.2.0618-trialRelease', ext:'aar')
compile (name:'Chart-2014.2.0618-trialRelease', ext:'aar')
package com.mycompany.myBusiness;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.view.ViewGroup;
import com.mycompany.myBusiness.R;
import com.telerik.widget.chart.engine.databinding.DataPointBinding;
import com.telerik.widget.chart.visualization.cartesianChart.RadCartesianChartView;
import com.telerik.widget.chart.visualization.cartesianChart.axes.CategoricalAxis;
import com.telerik.widget.chart.visualization.cartesianChart.axes.LinearAxis;
import com.telerik.widget.chart.visualization.cartesianChart.series.categorical.LineSeries;
import java.util.ArrayList;
import java.util.List;
/**
* Created by KuriaNdungu on 01/07/2014.
*/
public class activity_daily_log_chart extends ActionBarActivity {
boolean blnSufficientDataForChart=false;
CategoricalAxis horizontalAxis;
LinearAxis verticalAxis;
List<MonthResults> monthResults;
LineSeries lineSeries;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_daily_log_charts);
initData();
RadCartesianChartView chartView = new RadCartesianChartView(this);
ViewGroup rootView =(ViewGroup) findViewById(R.id.container);
rootView.addView(chartView);
lineSeries = new LineSeries(this);
lineSeries.setCategoryBinding(new DataPointBinding() {
@Override
public Object getValue(Object o) throws IllegalArgumentException {
return ((MonthResults)o).getMonth();
}
});
lineSeries.setValueBinding(new DataPointBinding() {
@Override
public Object getValue(Object o) throws IllegalArgumentException {
return ((MonthResults)o).getResult();
}
});
lineSeries.setData(this.monthResults);
CategoricalAxis horizontalAxis = new CategoricalAxis(this);
LinearAxis verticalAxis = new LinearAxis(this);
chartView.setVerticalAxis(verticalAxis);
chartView.setHorizontalAxis(horizontalAxis);
chartView.getSeries().add(lineSeries);
}
private void initData() {
monthResults=new ArrayList<MonthResults>();
monthResults.add(new MonthResults("Jan",24));
monthResults.add(new MonthResults("Feb",20));
monthResults.add(new MonthResults("Mar",15));
monthResults.add(new MonthResults("Apr",17));
monthResults.add(new MonthResults("May",21));
monthResults.add(new MonthResults("Jun",28));
monthResults.add(new MonthResults("Jul",32));
monthResults.add(new MonthResults("Aug",48));
monthResults.add(new MonthResults("Sep",51));
monthResults.add(new MonthResults("Oct",42));
monthResults.add(new MonthResults("Nov",57));
monthResults.add(new MonthResults("Dec",60));
}
}
--------------monthResults Class -----------------------
package com.mycompany.myBusiness;
/**
* Created by KuriaNdungu on 02/07/2014.
*/
public class MonthResults {
private String month;
private double result;
public MonthResults(String month,double result){
this.setMonth(month);
this.setResult(result);
}
public String getMonth() {
return month;
}
public void setMonth(String month) {
this.month = month;
}
public double getResult() {
return result;
}
public void setResult(double result) {
this.result = result;
}
}
I decided to replicate line for line the example provided here https://www.youtube.com/watch?v=JStf9gekJCM so as to see if i could get a working example.
A number of things happened.
1. in the video he uses code like RadCartesianChartView chartView = new RadCartesianChartView(this.getBaseContext()); replicating this resulted in an error and the program would not run. I had to use just "this" instead of this.getBaseContext()
2. The example does not run unless you move chartView.getSeries().add(lineSeries); as the last line in the code. placing it where it is shown in the video results in the example crashing. Not sure whether its an issue with my version.
3. When the example runs, it shows the graph but within the graph there are 4 lines stating a)NoHorizontalAxis, b) NoVerticalAxis , c)NoSeries and d) NoData. This is clearly not true since it is displaying the graph. I've attached a screenshot along with the code i'm using.
I'm using Android Studio (Beta) 0.8.1 and appcompat ver 7.19 along with corresponding support ActionBar
Unfortunately I'm unable to upload the screenshot even though its only 97kb. The uploader complains...not sure why.
-----code----
---Gradle Dependencies
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:19.1.0'
compile 'com.android.support:support-v4:18.0.+'
compile files('libs/socialauth-4.3.jar')
compile files('libs/bugsense-3.5.jar')
compile files('libs/httpmime-4.2.5.jar')
compile files('libs/libGoogleAnalyticsServices.jar')
compile files('libs/socialauth-4.3.jar')
compile (name:'Common-2014.2.0618-trialRelease', ext:'aar')
compile (name:'Primitives-2014.2.0618-trialRelease', ext:'aar')
compile (name:'Chart-2014.2.0618-trialRelease', ext:'aar')
package com.mycompany.myBusiness;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.view.ViewGroup;
import com.mycompany.myBusiness.R;
import com.telerik.widget.chart.engine.databinding.DataPointBinding;
import com.telerik.widget.chart.visualization.cartesianChart.RadCartesianChartView;
import com.telerik.widget.chart.visualization.cartesianChart.axes.CategoricalAxis;
import com.telerik.widget.chart.visualization.cartesianChart.axes.LinearAxis;
import com.telerik.widget.chart.visualization.cartesianChart.series.categorical.LineSeries;
import java.util.ArrayList;
import java.util.List;
/**
* Created by KuriaNdungu on 01/07/2014.
*/
public class activity_daily_log_chart extends ActionBarActivity {
boolean blnSufficientDataForChart=false;
CategoricalAxis horizontalAxis;
LinearAxis verticalAxis;
List<MonthResults> monthResults;
LineSeries lineSeries;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_daily_log_charts);
initData();
RadCartesianChartView chartView = new RadCartesianChartView(this);
ViewGroup rootView =(ViewGroup) findViewById(R.id.container);
rootView.addView(chartView);
lineSeries = new LineSeries(this);
lineSeries.setCategoryBinding(new DataPointBinding() {
@Override
public Object getValue(Object o) throws IllegalArgumentException {
return ((MonthResults)o).getMonth();
}
});
lineSeries.setValueBinding(new DataPointBinding() {
@Override
public Object getValue(Object o) throws IllegalArgumentException {
return ((MonthResults)o).getResult();
}
});
lineSeries.setData(this.monthResults);
CategoricalAxis horizontalAxis = new CategoricalAxis(this);
LinearAxis verticalAxis = new LinearAxis(this);
chartView.setVerticalAxis(verticalAxis);
chartView.setHorizontalAxis(horizontalAxis);
chartView.getSeries().add(lineSeries);
}
private void initData() {
monthResults=new ArrayList<MonthResults>();
monthResults.add(new MonthResults("Jan",24));
monthResults.add(new MonthResults("Feb",20));
monthResults.add(new MonthResults("Mar",15));
monthResults.add(new MonthResults("Apr",17));
monthResults.add(new MonthResults("May",21));
monthResults.add(new MonthResults("Jun",28));
monthResults.add(new MonthResults("Jul",32));
monthResults.add(new MonthResults("Aug",48));
monthResults.add(new MonthResults("Sep",51));
monthResults.add(new MonthResults("Oct",42));
monthResults.add(new MonthResults("Nov",57));
monthResults.add(new MonthResults("Dec",60));
}
}
--------------monthResults Class -----------------------
package com.mycompany.myBusiness;
/**
* Created by KuriaNdungu on 02/07/2014.
*/
public class MonthResults {
private String month;
private double result;
public MonthResults(String month,double result){
this.setMonth(month);
this.setResult(result);
}
public String getMonth() {
return month;
}
public void setMonth(String month) {
this.month = month;
}
public double getResult() {
return result;
}
public void setResult(double result) {
this.result = result;
}
}