3131import ie .tcd .pavel .security .SecurityUtils ;
3232import ie .tcd .pavel .utility .ExerciseTypes ;
3333
34+ import javax .management .Notification ;
35+
3436@ Route ("charts" )
3537public class ExerciseChartsPage extends VerticalLayout {
3638
@@ -42,7 +44,7 @@ public class ExerciseChartsPage extends VerticalLayout {
4244 public ExerciseChartsPage () {
4345 database = BeanUtil .getBean (MongoDBOperations .class );
4446 exerciseTypes = BeanUtil .getBean (ExerciseTypes .class );
45-
47+
4648 String [] exercises = exerciseTypes .getExerciseTypes ();
4749 List <Group > groups = database .getGroupsByUser (SecurityUtils .getUsername ());
4850 User currentUser = database .getUserByLogin (SecurityUtils .getUsername ());
@@ -63,9 +65,12 @@ public ExerciseChartsPage() {
6365 comboBoxExercise .setLabel ("Exercise" );
6466 comboBoxExercise .setItems (exercises );
6567 comboBoxExercise .addValueChangeListener (exerciseEvent ->{
66- HashMap <User , Double > data = database .inGroupGetCumulativeValuesByUserAndType (comboBoxGroup .getValue (), comboBoxExercise .getValue ());
68+ HashMap <User , Double > data = database .inGroupGetCumulativeValuesByUserAndType (comboBoxGroup .getValue (),
69+ comboBoxExercise .getValue ());
70+
6771
6872 Chart pieChart = new Chart (ChartType .PIE );
73+ horizontalLayout .remove (pieChart );
6974 Configuration pieChartConfig = pieChart .getConfiguration ();
7075 pieChartConfig .setTitle ("Member Contribution" );
7176 pieChartConfig .setSubTitle (comboBoxExercise .getValue ());
@@ -81,13 +86,8 @@ public ExerciseChartsPage() {
8186 pieChartConfig .setPlotOptions (plotOptions );
8287
8388 DataSeries dataSeries = new DataSeries ();
84- dataSeries .clear ();
85- DataSeriesItem currentUserSeries = new DataSeriesItem (currentUser .getLogin (), data .get (currentUser ));
86- currentUserSeries .setSliced (true );
87- currentUserSeries .setSelected (true );
88- dataSeries .add (currentUserSeries );
8989 for (int i = 0 ; i <database .getUsersByGroup (comboBoxGroup .getValue ()).size (); i ++)
90- {
90+ {
9191 User user = database .getUsersByGroup (comboBoxGroup .getValue ()).get (i );
9292 dataSeries .add (new DataSeriesItem (user .getLogin (), data .get (user )));
9393 }
0 commit comments