Inicio soporte graficos, añadido soporte para diferenciar gastos e

ingresos
This commit is contained in:
2019-11-12 21:48:19 +01:00
parent 8af689363a
commit ba84d7d15b
10 changed files with 76 additions and 23 deletions

View File

@@ -2,21 +2,33 @@ package VistaControlador;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartFrame;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.plot.Plot;
import org.jfree.chart.plot.XYPlot;
import org.jfree.data.xy.XYSeries;
import org.jfree.data.xy.XYSeriesCollection;
public class ControladorPanelLateral implements ActionListener{
private VistaPanelLateral vista;
public ControladorPanelLateral(VistaPanelLateral vista) {
this.vista=vista;
this.aniadirElementos();
}
public void actionPerformed(ActionEvent e) {
if(e.getActionCommand().equals(this.vista.mostrarEstadisticas.getActionCommand())) {
XYPlot plot=new XYPlot();
JFreeChart chart=new JFreeChart(plot);
XYSeries serie=new XYSeries("Mes");
serie.add(10,1);
serie.add(4,2);
serie.add(90,10);
XYSeriesCollection dataset=new XYSeriesCollection(serie);
JFreeChart chart=ChartFactory.createXYLineChart("Mes", "Dias", "Gastos", dataset);
ChartFrame frame=new ChartFrame("Estadisricas", chart);
frame.setVisible(true);
frame.setSize(700,500);
}else if(e.getActionCommand().equals(this.vista.elegirMes.getActionCommand())){
}
}
@@ -24,6 +36,8 @@ public class ControladorPanelLateral implements ActionListener{
private void aniadirElementos() {
this.vista.mostrarEstadisticas.addActionListener(this);
this.vista.mostrarEstadisticas.setActionCommand("Mostrar estadisticas");
this.vista.elegirMes.addActionListener(this);
this.vista.elegirMes.setActionCommand("Elegir mes");
}
}