forked from AY2425S1-CS2103T-T14-4/tp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request AY2425S1-CS2103T-T14-4#178 from iamdiluxedbutcoole…
…r/ui-diagram-update-panel Add panel and graph
- Loading branch information
Showing
6 changed files
with
272 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
package seedu.address.ui; | ||
|
||
import javafx.application.Platform; | ||
import javafx.collections.FXCollections; | ||
import javafx.collections.ObservableList; | ||
import javafx.fxml.FXML; | ||
import javafx.geometry.Insets; | ||
import javafx.geometry.Side; | ||
import javafx.scene.chart.PieChart; | ||
import javafx.scene.control.Label; | ||
import javafx.scene.layout.Region; | ||
import javafx.scene.layout.VBox; | ||
|
||
/** | ||
* Panel containing the status distribution pie chart. | ||
*/ | ||
public class StatusPieChart extends UiPart<Region> { | ||
|
||
private static final String FXML = "StatusPieChart.fxml"; | ||
@FXML | ||
private VBox chartContainer; | ||
|
||
@FXML | ||
private Label chartTitle; | ||
|
||
@FXML | ||
private PieChart statusChart; | ||
|
||
/** | ||
* Creates a new StatusPieChart. | ||
* Initializes the chart with default settings by calling setupChart(). | ||
*/ | ||
public StatusPieChart() { | ||
super(FXML); | ||
setupChart(); | ||
} | ||
|
||
/** | ||
* Sets up the initial configuration of the pie chart. | ||
* This includes: | ||
* - Setting the chart title | ||
* - Configuring chart display properties (labels, legend, size) | ||
* - Setting up the chart container | ||
* - Applying custom styling | ||
*/ | ||
private void setupChart() { | ||
chartTitle.setText("CLIENT STATUS"); | ||
statusChart.setTitle(""); | ||
statusChart.setLabelsVisible(false); | ||
statusChart.setLegendVisible(true); | ||
statusChart.setLegendSide(Side.BOTTOM); | ||
|
||
statusChart.setPrefSize(200, 200); | ||
statusChart.setMinSize(180, 180); | ||
statusChart.setMaxSize(Double.MAX_VALUE, Double.MAX_VALUE); | ||
|
||
chartContainer.setPadding(new Insets(2)); | ||
|
||
statusChart.getStyleClass().add("status-chart"); | ||
} | ||
|
||
/** | ||
* Updates the pie chart with new status counts. | ||
* | ||
* @param noneCount Number of clients with NONE status | ||
* @param nonUrgentCount Number of clients with NON_URGENT status | ||
* @param urgentCount Number of clients with URGENT status | ||
*/ | ||
public void updateChartData(int noneCount, int nonUrgentCount, int urgentCount) { | ||
Platform.runLater(() -> { | ||
statusChart.getData().clear(); | ||
|
||
PieChart.Data noneData = new PieChart.Data("None (" + noneCount + ")", noneCount); | ||
PieChart.Data nonUrgentData = new PieChart.Data("Non-Urgent (" + nonUrgentCount + ")", nonUrgentCount); | ||
PieChart.Data urgentData = new PieChart.Data("Urgent (" + urgentCount + ")", urgentCount); | ||
|
||
ObservableList<PieChart.Data> pieChartData = FXCollections.observableArrayList( | ||
noneData, nonUrgentData, urgentData | ||
); | ||
|
||
statusChart.setData(pieChartData); | ||
|
||
noneData.getNode().getStyleClass().add("data0"); | ||
nonUrgentData.getNode().getStyleClass().add("data1"); | ||
urgentData.getNode().getStyleClass().add("data2"); | ||
|
||
statusChart.applyCss(); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<?import javafx.scene.chart.PieChart?> | ||
<?import javafx.scene.control.Label?> | ||
<?import javafx.scene.layout.VBox?> | ||
<?import java.net.URL?> | ||
|
||
<VBox fx:id="chartContainer" alignment="CENTER" spacing="0" fillWidth="true" | ||
xmlns="http://javafx.com/javafx/17" | ||
xmlns:fx="http://javafx.com/fxml/1"> | ||
<stylesheets> | ||
<URL value="@css/DarkTheme.css" /> | ||
<URL value="@css/StatusPieChart.css" /> | ||
</stylesheets> | ||
|
||
<Label fx:id="chartTitle" styleClass="chart-title"/> | ||
<PieChart fx:id="statusChart" VBox.vgrow="ALWAYS" legendSide="BOTTOM"/> | ||
</VBox> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* Chart container styles */ | ||
.chart-container { | ||
-fx-background-color: #1C1C1C; | ||
-fx-padding: 2; | ||
} | ||
|
||
/* Chart title styles */ | ||
.chart-title { | ||
-fx-text-fill: white; | ||
-fx-font-size: 16px; | ||
-fx-padding: 0 0 -2 0; | ||
-fx-font-weight: bold; | ||
} | ||
|
||
/* General pie chart styles */ | ||
.chart-pie { | ||
-fx-border-width: 0; | ||
-fx-padding: 0 0 0 2; | ||
} | ||
|
||
/* Data-specific styles for pie slices */ | ||
.chart-pie.data0 { | ||
-fx-pie-color: #009E60; | ||
} | ||
|
||
.chart-pie.data1 { | ||
-fx-pie-color: #c46210; | ||
} | ||
|
||
.chart-pie.data2 { | ||
-fx-pie-color: #FF2400; | ||
} | ||
|
||
/* Legend styles */ | ||
.chart-legend { | ||
-fx-background-color: transparent; | ||
-fx-padding: 10 5 5 5; | ||
} | ||
|
||
.chart-legend-item { | ||
-fx-text-fill: white; | ||
-fx-font-size: 14px; | ||
} | ||
|
||
.chart-legend-item-symbol { | ||
-fx-padding: 3px; | ||
-fx-min-width: 8px; | ||
-fx-min-height: 8px; | ||
} | ||
|
||
/* Status chart placeholder dimensions */ | ||
.status-chart-placeholder { | ||
-fx-min-height: 220px; | ||
-fx-max-height: 220px; | ||
} |