Merge remote-tracking branch 'origin/main'

This commit is contained in:
OmarVX 2024-03-18 18:11:03 -06:00
commit 2e6078142d
2 changed files with 90 additions and 0 deletions

View File

@ -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 <String, XYChart.Series> 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;
}
}

View File

@ -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);
}
}