Skip to content

Commit

Permalink
Merge pull request #97 from einaskoi/einar/Chart
Browse files Browse the repository at this point in the history
change to areachart and altered stock resolution to fit a full week
  • Loading branch information
peretr authored May 13, 2026
2 parents aee7283 + ae95b7f commit f6887b1
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public final class MarketController {
* Constructs a new MarketController and starts the market.
*/
public MarketController() {
this.stockResolution = 50;
this.stockResolution = 120;

try {
Path path = Path.of(Objects.requireNonNull(getClass().getClassLoader()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import edu.ntnu.idi.idatt2003.gruppe42.Model.Stock;
import javafx.application.Platform;
import javafx.scene.chart.LineChart;
import javafx.scene.chart.AreaChart;
import javafx.scene.chart.NumberAxis;
import javafx.scene.chart.XYChart;
import javafx.scene.layout.VBox;
Expand All @@ -14,7 +14,7 @@
* Component for displaying a stock price history graph.
*/
public final class StockGraph extends VBox {
private final LineChart<Number, Number> lineChart;
private final AreaChart<Number, Number> areaChart;
private boolean isVisible = false;

/**
Expand All @@ -32,14 +32,14 @@ public StockGraph() {
yAxis.setLabel("Price");
yAxis.setAutoRanging(true);

lineChart = new LineChart<>(xAxis, yAxis);
lineChart.getStyleClass().add("stock-line-chart");
lineChart.setPrefSize(500, 250);
lineChart.setCreateSymbols(false);
lineChart.setLegendVisible(false);
lineChart.setAnimated(false);
areaChart = new AreaChart<>(xAxis, yAxis);
areaChart.getStyleClass().add("stock-area-chart");
areaChart.setPrefSize(500, 250);
areaChart.setCreateSymbols(false);
areaChart.setLegendVisible(false);
areaChart.setAnimated(false);

getChildren().add(lineChart);
getChildren().add(areaChart);
}

/**
Expand All @@ -64,7 +64,7 @@ public void update(final Stock stock) {
);

Platform.runLater(() -> {
lineChart.getData().clear();
areaChart.getData().clear();

XYChart.Series<Number, Number> series = new XYChart.Series<>();
series.setName(stock.getCompany());
Expand All @@ -73,7 +73,7 @@ public void update(final Stock stock) {
series.getData().add(new XYChart.Data<>(i, latestHistory.get(i)));
}

lineChart.getData().add(series);
areaChart.getData().add(series);
});
}

Expand Down
32 changes: 28 additions & 4 deletions src/main/resources/css/apps.css
Original file line number Diff line number Diff line change
Expand Up @@ -179,26 +179,50 @@
-fx-background-color: white;
}

.stock-line-chart {
.stock-area-chart {
-fx-create-symbols: false;
-fx-horizontal-grid-lines-visible: false;
-fx-vertical-grid-lines-visible: false;
}

.stock-line-chart .chart-series-line {
/* The actual line */
.stock-area-chart .chart-series-area-line {
-fx-stroke: #007AFF;
-fx-stroke-width: 2px;
}

.stock-line-chart .chart-plot-background {
/* The filled area */
.stock-area-chart .chart-series-area-fill {
-fx-fill: rgba(0, 122, 255, 0.15);
}

/* Background */
.stock-area-chart .chart-plot-background {
-fx-background-color: transparent;
}

.stock-line-chart .axis {
/* Axes */
.stock-area-chart .axis {
-fx-tick-label-fill: #888888;
-fx-tick-length: 5;
}

/* Receipt */
.receipt-container {
-fx-background-color: white;
-fx-border-color: #cccccc;
-fx-border-style: dashed;
-fx-padding: 20;
-fx-effect: dropshadow(
three-pass-box,
rgba(0,0,0,0.1),
5,
0,
0,
2
);
}

/* Receipt */
.receipt-container {
-fx-background-color: white;
Expand Down

0 comments on commit f6887b1

Please sign in to comment.