Hello Jay,
Thank you for contacting the Android team.
I reviewed your sample code and I didn't find anything wrong with it. I got a doughnut chart with 3 values visible on my screen.
The android platform might sometimes prove to be tricky when debugging. I recommend you to go from the bottom up. First make sure you get the wanted result in the most simple way possible:
public
class
MainActivity extends ActionBarActivity {
@Override
protected
void
onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(pieChartView());
}
public
RadPieChartView pieChartView() {
RadPieChartView doughnutchartView =
null
;
try
{
initData();
doughnutchartView =
new
RadPieChartView(
this
);
DoughnutSeries doughnutSeries =
new
DoughnutSeries(
this
);
doughnutSeries.setValueBinding(
new
DataPointBinding() {
@Override
public
Object getValue(Object o) {
return
((MonthResults) o).getResult();
}
});
doughnutSeries.setData(
this
.monthResults);
doughnutchartView.getSeries().add(doughnutSeries);
}
catch
(Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return
doughnutchartView;
}
List<MonthResults> monthResults;
private
void
initData() {
monthResults =
new
ArrayList<MonthResults>();
monthResults.add(
new
MonthResults(
"Jan"
, 25, 10));
monthResults.add(
new
MonthResults(
"Feb"
, 30, 10));
monthResults.add(
new
MonthResults(
"Mar"
, 40, 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));
}
public
class
MonthResults {
private
String month;
private
double
result, resultY;
public
double
getResultY() {
return
resultY;
}
public
void
setResultY(
double
resultY) {
this
.resultY = resultY;
}
public
MonthResults(String month,
double
i,
double
d) {
this
.setMonth(month);
this
.setResult(i);
this
.setResultY(d);
}
public
double
getResult() {
return
result;
}
public
void
setResult(
double
result) {
this
.result = result;
}
public
String getMonth() {
return
month;
}
public
void
setMonth(String month) {
this
.month = month;
}
}
}
Here is your code inside a simple activity without any use of xml or fragments. I am just calling the setContentView(pieChartView()); so that I can make sure this code works.
It apparently does on my side, so I would go from there and check first the xml and the way the chart is being added to the layout, then the way the fragment is being set and added to the context. Somewhere there lies the issue.
If you are creating the chart in the code rather that the xml layout, you might want to specify the layout parameters of the chart when adding it to the layout. The chart needs to be set to MATCH_PARENT for both width and height and the parent must not depend on the chart to know its size.
I would be happy to help you out further if you need me to, but I will need to see some more of your code, since the snippet you sent me is perfectly fine.
Let me know how this goes.
Thank you for your time and all best!
Regards,
Antony Jekov
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.