I am reading from a csv file formatted with a student name, date they are absent, and an integer value of 1. The file looks like this:
Jim,8/19/2016,1
Jim,8/20/2016,1
I am plotting this data on a piechart using JFreeChart, and I can set labels to show the sum of absences for each student or the percentage, but I want to store the sum and percentage as variables and use them later in my code. How do I do this? My next step would be seeing if Jim missed more than 25% of the days in the school year.
DatasetUtilities.calculatePieDatasetTotal
"Calculates the total of all the values in a PieDataset
." The corresponding source shows a typical iteration scheme.
List keys = dataset.getKeys();
while (iterator.hasNext()) {
Comparable current = (Comparable) iterator.next();
Number value = dataset.getValue(current);
…
}
You can change the displayed percentage labels as shown here.
In your next step, the number of days in the school year is particular to a given school system. the number of days should be supplied as a parameter to the method that iterates through the PieDataset
.