I am trying to make it that every element in the arraylist needs_elements
is populated on a graph. Right now I am doing it very repetitively. My code is below:
ArrayList
Root C = gson.fromJson(profile.toString(), Root.class);
ArrayList<Double> percentagesList = new ArrayList();
Root.SubTree t = C.getSubTree(); //Gets subtree from root
ArrayList<Children> c = t.getChildren();
Children needs = c.get(1);
ArrayList<Children1> needsChildren = needs.getChildren();
Children1 needsChildren1 = needsChildren.get(0);
ArrayList <Children2> needs_elements = needsChildren1.getChildren(); //ELEMENTS FROM THIS ARRAYLIST
My way
double CHTotal = 0;
percentagesList.add(needs_elements.get(0).getPercentage());
CHTotal = needs_elements.get(0).getPercentage();
System.out.println(CHTotal);
//--------------Barchart-----------------------------------------------------
dcd.setValue(CHTotal, "Percentage", "Openness"); //Show here
JFreeChart jchart = ChartFactory.createBarChart3D("Arrays", "Types","Percentage" , dcd, PlotOrientation.VERTICAL,true,true,false ); //chart
CategoryPlot plot = jchart.getCategoryPlot();
ChartFrame chartFRM = new ChartFrame("Student Records", jchart,true);
chartFRM.setVisible(true);
chartFRM.setSize(500,400);
I have to do this for about 10+ elements. Is there a way I can automatically get each element in the needs_elements
arraylist and make it increment in the barchart? Thanks for your time:)