Skip to content

Commit

Permalink
fixed and home dashboard done
Browse files Browse the repository at this point in the history
  • Loading branch information
AkashDeepSinghJassal committed Feb 3, 2021
1 parent e30a368 commit b93268c
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 22 deletions.
3 changes: 2 additions & 1 deletion src/hospital/ui/css/Stage.css
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
}
.chart-title {
-fx-text-fill: #fff;
-fx-font-size: 20.0px;
-fx-font-size: 30.0px;
-fx-opacity : 0.9;
}
.default-color0.chart-bar {
-fx-bar-fill: #2b48b3;
Expand Down
4 changes: 2 additions & 2 deletions src/hospital/ui/view/home/HomeOverview.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<children>
<AnchorPane prefHeight="100.0" prefWidth="1920.0" styleClass="background" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<children>
<Label layoutX="783.0" layoutY="6.0" prefHeight="88.0" prefWidth="412.0" styleClass="label-header" text="Home Overview" AnchorPane.bottomAnchor="6.0" AnchorPane.topAnchor="6.0" />
<Label layoutX="783.0" layoutY="6.0" prefHeight="88.0" prefWidth="412.0" styleClass="label-header" text="Dashboard" AnchorPane.bottomAnchor="6.0" AnchorPane.topAnchor="6.0" />
</children>
</AnchorPane>
<AnchorPane fx:id="homeAnchor" layoutX="10.0" layoutY="10.0" prefHeight="980.0" prefWidth="1920.0" styleClass="background" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="100.0">
Expand Down Expand Up @@ -63,7 +63,7 @@
</Pane>
<Pane layoutX="1453.0" layoutY="76.0" prefHeight="146.0" prefWidth="332.0" style="-fx-border-color: #FDFF00;" AnchorPane.rightAnchor="200.0" AnchorPane.topAnchor="50.0">
<children>
<Label layoutX="48.0" layoutY="24.0" prefHeight="31.0" prefWidth="241.0" styleClass="label-bright" text="Patient" />
<Label layoutX="46.0" layoutY="18.0" prefHeight="31.0" prefWidth="241.0" styleClass="label-bright" text="Patient" />
<Label fx:id="patientLbl" layoutX="141.0" layoutY="68.0" text="Label">
<styleClass>
<String fx:value="sub-label" />
Expand Down
54 changes: 35 additions & 19 deletions src/hospital/ui/view/home/HomeOverviewController.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,19 @@ public class HomeOverviewController {
@FXML
private AnchorPane homeAnchor;
@FXML
private Label appointmentLbl;
private Label appointmentLbl;

@FXML
private Label doctorLbl;
@FXML
private Label doctorLbl;

@FXML
private Label patientLbl;
@FXML
private Label patientLbl;

public AnchorPane overlay = null;
private ObservableList<LocalDate> dayList;
private ObservableList<AppointmentCalendar> appointmentCalander;
private int totalAppointAvail;

/**
* Initializes the controller class. This method is automatically called after
* the fxml file has been loaded.
Expand All @@ -57,20 +58,22 @@ private void initialize() {
// updateStatistics();
caption.setLayoutX(-100);
caption.setLayoutY(-100);
pieChart.setLabelLineLength(10);
pieChart.setLegendSide(Side.LEFT);
}

public void updateStatistics() {
//update label
// update label
int totalPatients = Main.patientOverviewController.getObservableList().size();
patientLbl.setText(totalPatients + "");

int totalDoctors = Main.doctorOverviewController.getObservableList().size();
doctorLbl.setText(totalDoctors + "");
// 8 hrs per 15 min
totalAppointAvail = totalDoctors * 32;
int totalAppoint = Main.appointmentOverviewController.getObservableList().size();
appointmentLbl.setText(totalAppoint + "");

barChart.getData().clear();
LocalDate nowDate = LocalDate.now();
dayList = FXCollections.observableArrayList();
Expand Down Expand Up @@ -115,34 +118,47 @@ private void buildBarChart(HashMap<LocalDate, Integer> appointmentCountMap) {
.add(new XYChart.Data<String, Integer>(dates.get(i), appointmentCountMap.get(dayList.get(i))));
}
barChart.getData().add(series);
buildPieChart(series.getData().get(0).getYValue(), totalAppointAvail);
buildPieChart(series.getData().get(0).getYValue(), totalAppointAvail, series.getData().get(0).getXValue());
for (XYChart.Data<String, Integer> data : series.getData()) {
data.getNode().addEventHandler(MouseEvent.MOUSE_MOVED, e -> {

caption.setMinWidth(30);
caption.setLayoutX(e.getSceneX());
caption.setLayoutY(e.getSceneY());
caption.setOpacity(1);
caption.setLayoutY(e.getSceneY() - 75);
caption.setText(data.getYValue().toString());
buildPieChart(data.getYValue(), totalAppointAvail);
// buildPieChart(data.getYValue(), totalAppointAvail);
});
data.getNode().addEventHandler(MouseEvent.MOUSE_CLICKED, e -> {
buildPieChart(data.getYValue(), totalAppointAvail, data.getXValue());
});
data.getNode().addEventHandler(MouseEvent.MOUSE_EXITED, e -> {

caption.setLayoutX(-100);
caption.setLayoutY(-100);
caption.setText("");
caption.setOpacity(0);
});
}
}

private void buildPieChart(int filled, int vacant) {
private void buildPieChart(int filled, int vacant, String dataTitle) {
pieChart.getData().clear();
homeAnchor.layout();
ObservableList<PieChart.Data> pieChartData = FXCollections.observableArrayList(new PieChart.Data("Filled", filled),
new PieChart.Data("Vacant", vacant));
pieChart.setTitle("Appointment Ratio");
ObservableList<PieChart.Data> pieChartData = FXCollections
.observableArrayList(new PieChart.Data("Filled", filled), new PieChart.Data("Vacant", vacant));
pieChart.setTitle(dataTitle);
pieChart.getData().addAll(pieChartData);
pieChart.setLabelLineLength(10);
pieChart.setLegendSide(Side.LEFT);
int total = filled + vacant;
for (PieChart.Data data : pieChart.getData()) {
data.getNode().addEventHandler(MouseEvent.MOUSE_MOVED, e -> {
caption.setLayoutX(e.getSceneX());
caption.setLayoutY(e.getSceneY());
caption.setText(String.format("%.1f %s", (double) data.getPieValue() * 100 / total, "%"));
caption.setMinWidth(75);
});
data.getNode().addEventHandler(MouseEvent.MOUSE_EXITED, e -> {
caption.setLayoutX(-100);
caption.setLayoutY(-100);
});
}
}
}

0 comments on commit b93268c

Please sign in to comment.