java - how to use Arraylist (for-loop) in Jfreechart piechart? -
i started on collecting data in database, wrote code retrieves information, name(language) , amount of times language has been counted, arraylist. data wanted make piechart.
i have tried jfreechart
does know how use data in arraylist piechart createdataset code jfreechart , since attempts resulted in failure(empty piechart) while using loop in the method ,createdataset, since data in arraylist changes , therefore dont want hardcode values , names.
for loop attempt(everything else left default):
public piedataset createdataset() { defaultpiedataset result = new defaultpiedataset(); for(language l: languagelist){ result.setvalue( l.getname(), l.getcount()); } return result; }
if loop possible doing wrong or has change tom make work, if i'm off want know.
--edit--
public piedataset createdataset() { defaultpiedataset result = new defaultpiedataset(); int count = 0; for(language l: languagelist){ result.insertvalue(count++, l.getname(), l.getcount()); } return result; }
try using insertvalue api like:
int count = 0; for(language l: languagelist){ result.insertvalue(count++, l.getname(), l.getcount()); }
Comments
Post a Comment