From 77fd00ca43c18f6a0bbe33ac41a6a45b5e54efd9 Mon Sep 17 00:00:00 2001 From: 03jossellin-herrera-rodriguez Date: Mon, 18 Mar 2024 17:43:07 -0600 Subject: [PATCH] Commit graficasBarras --- .../ConstructorGraficaBarras.java | 63 +++++++++++++++++++ .../presentadorjfx/NC_GraficaBarras.java | 27 ++++++++ 2 files changed, 90 insertions(+) create mode 100644 PresentadorJFX/src/main/java/com/mycompany/presentadorjfx/ConstructorGraficaBarras.java create mode 100644 PresentadorJFX/src/main/java/com/mycompany/presentadorjfx/NC_GraficaBarras.java diff --git a/PresentadorJFX/src/main/java/com/mycompany/presentadorjfx/ConstructorGraficaBarras.java b/PresentadorJFX/src/main/java/com/mycompany/presentadorjfx/ConstructorGraficaBarras.java new file mode 100644 index 0000000..4a66508 --- /dev/null +++ b/PresentadorJFX/src/main/java/com/mycompany/presentadorjfx/ConstructorGraficaBarras.java @@ -0,0 +1,63 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/javafx/FXMain.java to edit this template + */ +package com.mycompany.presentadorjfx; + +import javafx.application.Application; +import javafx.event.ActionEvent; +import javafx.event.EventHandler; +import javafx.scene.Scene; +import javafx.scene.control.Button; +import javafx.scene.layout.StackPane; +import javafx.stage.Stage; + +import java.util.HashMap; +import java.util.Map; +import javafx.scene.chart.CategoryAxis; +import javafx.scene.chart.NumberAxis; +import javafx.scene.chart.XYChart; + +/** + * + * @author Jossellin + */ +public class ConstructorGraficaBarras { + private NC_GraficaBarras gb; + private Map series; + + public ConstructorGraficaBarras(String Titulo, String ejeX, String ejeY) { + // Da nombre al ejeX + CategoryAxis xAxis = new CategoryAxis(); + xAxis.setLabel(ejeX); + // Da nombre al ejeY + NumberAxis yAxis = new NumberAxis(); + yAxis.setLabel(ejeY); + gb = new NC_GraficaBarras(xAxis, yAxis); + gb.setTitle(Titulo); + gb.setMinSize(800, 500); + series = new HashMap<>(); + } + + public void agregaSerie(String nombre) { + XYChart.Series serie = new XYChart.Series(); + serie.setName(nombre); + series.put(nombre, serie); + } + + public void agregaBarraSerie(String nombreSerie, + String nombreBarra, + double valor) { + XYChart.Series serie = series.get(nombreSerie); + serie.getData().add(new XYChart.Data(nombreBarra, valor)); + } + + public NC_GraficaBarras generaGraficaBarras() { + for(XYChart.Series serie : series.values()) { + gb.getData().add(serie); + } + return gb; + } + + +} diff --git a/PresentadorJFX/src/main/java/com/mycompany/presentadorjfx/NC_GraficaBarras.java b/PresentadorJFX/src/main/java/com/mycompany/presentadorjfx/NC_GraficaBarras.java new file mode 100644 index 0000000..fb96629 --- /dev/null +++ b/PresentadorJFX/src/main/java/com/mycompany/presentadorjfx/NC_GraficaBarras.java @@ -0,0 +1,27 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/javafx/FXMain.java to edit this template + */ +package com.mycompany.presentadorjfx; + +import javafx.application.Application; +import javafx.event.ActionEvent; +import javafx.event.EventHandler; +import javafx.scene.Scene; +import javafx.scene.control.Button; +import javafx.scene.layout.StackPane; +import javafx.stage.Stage; + +import javafx.scene.chart.Axis; +import javafx.scene.chart.BarChart; +/** + * + * @author Jossellin + */ +public class NC_GraficaBarras extends BarChart { + + public NC_GraficaBarras(Axis xAxis, Axis yAxis) { + super(xAxis, yAxis); + } + +}