package visual.panel;

import javax.swing.*;
import javax.swing.border.Border;

import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.axis.CategoryAxis;
import org.jfree.chart.axis.ValueAxis;
import org.jfree.chart.plot.CategoryPlot;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.chart.renderer.category.BarRenderer;
import org.jfree.chart.renderer.category.StandardBarPainter;
import org.jfree.data.category.DefaultCategoryDataset;

import control.ControlPrincipal;

import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;

/**
 * Panel que contiene los resumenes de los datos del usuario. Esto a travez de
 * Jfreecharts principalmente
 */

public class PanelResumen extends JPanel {

	private JLabel balance;
	private JComboBox<String> boxGraph;
	private ArrayList<JTextField> egresos;
	private ArrayList<JTextField> ingresos;
	private ArrayList<JTextField> saldos;
	private ArrayList<JLabel> meses;
	private ChartPanel graphDocumento;
	private ChartPanel graphMes;
	private JLabel lEgr;
	private JLabel lIng;
	private JLabel lSaldo;
	private JPanel panelGraphs;
	private JLabel selectGraph;
	private Border borde;
	private String usuario;

	private DefaultCategoryDataset dataSetMes;
	private DefaultCategoryDataset dataSetDoc;

	/**
	 * Inicia el panelResumen y le asigna el usuario de quien sacara los datos.
	 * 
	 * @param usuario
	 *            Usuario al cual corresponden los datos que se mostraran.
	 */

	public PanelResumen(String usuario) {
		this.usuario = usuario;
		initComponents();
	}

	/**
	 * Inicia los componentes del panel
	 */

	private void initComponents() {

		iniciarTextFieldYLabel();
		lSaldo = new JLabel();
		balance = new JLabel();
		lIng = new JLabel();
		lEgr = new JLabel();
		selectGraph = new JLabel();
		boxGraph = new JComboBox<>();
		panelGraphs = new JPanel();
		graphMes = crearGraphMes();
		graphDocumento = crearGraphDoc();

		setBackground(new Color(0, 128, 128));

		lSaldo.setFont(new Font("Candara", 1, 14)); // NOI18N
		lSaldo.setForeground(new Color(255, 255, 255));
		lSaldo.setText("Saldo");

		balance.setFont(new Font("Candara", 1, 36)); // NOI18N
		balance.setForeground(new Color(255, 255, 255));
		balance.setText("Balance Mensual");

		lIng.setFont(new Font("Candara", 1, 14)); // NOI18N
		lIng.setForeground(new Color(255, 255, 255));
		lIng.setText("Ingresos");

		lEgr.setFont(new Font("Candara", 1, 14)); // NOI18N
		lEgr.setForeground(new Color(255, 255, 255));
		lEgr.setText("Egresos");

		selectGraph.setFont(new Font("Candara", 1, 14)); // NOI18N
		selectGraph.setForeground(new Color(255, 255, 255));
		selectGraph.setText("Seleccionar Grafico:");

		boxGraph.setBackground(new Color(178, 223, 219));
		boxGraph.setModel(new DefaultComboBoxModel<>(new String[] { "Mes", "Documento" }));
		boxGraph.setOpaque(false);
		boxGraph.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent evt) {

				comboActionPerformed(evt);

			}

		});

		panelGraphs.setBackground(new Color(51, 51, 51));
		panelGraphs.setLayout(new CardLayout());

		graphMes.setBackground(new Color(255, 255, 51));

		GroupLayout graphMesLayout = new GroupLayout(graphMes);
		graphMes.setLayout(graphMesLayout);
		graphMesLayout.setHorizontalGroup(
				graphMesLayout.createParallelGroup(GroupLayout.Alignment.LEADING).addGap(0, 0, Short.MAX_VALUE));
		graphMesLayout.setVerticalGroup(
				graphMesLayout.createParallelGroup(GroupLayout.Alignment.LEADING).addGap(0, 0, Short.MAX_VALUE));

		panelGraphs.add(graphMes, "Mes");

		graphDocumento.setBackground(new Color(255, 51, 51));

		GroupLayout graphDocumentoLayout = new GroupLayout(graphDocumento);
		graphDocumento.setLayout(graphDocumentoLayout);
		graphDocumentoLayout.setHorizontalGroup(graphDocumentoLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
				.addGap(0, 700, Short.MAX_VALUE));
		graphDocumentoLayout.setVerticalGroup(graphDocumentoLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
				.addGap(0, 465, Short.MAX_VALUE));

		panelGraphs.add(graphDocumento, "Documento");

		GroupLayout layout = new GroupLayout(this);
		this.setLayout(layout);
		layout.setHorizontalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
				.addGroup(layout.createSequentialGroup().addContainerGap()
						.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
								.addComponent(lEgr, GroupLayout.Alignment.TRAILING)
								.addComponent(lSaldo, GroupLayout.Alignment.TRAILING)
								.addComponent(lIng, GroupLayout.Alignment.TRAILING))
						.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
						.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
								.addComponent(balance, GroupLayout.PREFERRED_SIZE, 310,
										GroupLayout.PREFERRED_SIZE)
								.addGroup(layout.createSequentialGroup()
										.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
												.addComponent(saldos.get(0), GroupLayout.PREFERRED_SIZE, 63,
														GroupLayout.PREFERRED_SIZE)
												.addComponent(egresos.get(0), GroupLayout.PREFERRED_SIZE, 63,
														GroupLayout.PREFERRED_SIZE)
												.addComponent(ingresos.get(0), GroupLayout.PREFERRED_SIZE, 63,
														GroupLayout.PREFERRED_SIZE)
												.addComponent(meses.get(0)))
										.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
										.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
												.addComponent(saldos.get(1), GroupLayout.PREFERRED_SIZE, 63,
														GroupLayout.PREFERRED_SIZE)
												.addComponent(egresos.get(1), GroupLayout.PREFERRED_SIZE, 63,
														GroupLayout.PREFERRED_SIZE)
												.addComponent(ingresos.get(1), GroupLayout.PREFERRED_SIZE, 63,
														GroupLayout.PREFERRED_SIZE)
												.addComponent(meses.get(1)))
										.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
										.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
												.addComponent(saldos.get(2), GroupLayout.PREFERRED_SIZE, 63,
														GroupLayout.PREFERRED_SIZE)
												.addComponent(egresos.get(2), GroupLayout.PREFERRED_SIZE, 63,
														GroupLayout.PREFERRED_SIZE)
												.addComponent(ingresos.get(2), GroupLayout.PREFERRED_SIZE, 63,
														GroupLayout.PREFERRED_SIZE)
												.addComponent(meses.get(2)))
										.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
										.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
												.addComponent(saldos.get(3), GroupLayout.PREFERRED_SIZE, 63,
														GroupLayout.PREFERRED_SIZE)
												.addComponent(egresos.get(3), GroupLayout.PREFERRED_SIZE, 63,
														GroupLayout.PREFERRED_SIZE)
												.addComponent(ingresos.get(3), GroupLayout.PREFERRED_SIZE, 63,
														GroupLayout.PREFERRED_SIZE)
												.addComponent(meses.get(3)))
										.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
										.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
												.addComponent(saldos.get(4), GroupLayout.PREFERRED_SIZE, 63,
														GroupLayout.PREFERRED_SIZE)
												.addComponent(meses.get(4))
												.addComponent(egresos.get(4), GroupLayout.PREFERRED_SIZE, 63,
														GroupLayout.PREFERRED_SIZE)
												.addComponent(ingresos.get(4), GroupLayout.PREFERRED_SIZE, 63,
														GroupLayout.PREFERRED_SIZE))
										.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
										.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING, false)
												.addComponent(meses.get(5))
												.addComponent(saldos.get(5), GroupLayout.DEFAULT_SIZE, 63,
														Short.MAX_VALUE)
												.addComponent(egresos.get(5)).addComponent(ingresos.get(5)))))
						.addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
						.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
								.addGroup(layout.createSequentialGroup().addComponent(selectGraph)
										.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
										.addComponent(boxGraph, GroupLayout.PREFERRED_SIZE, 119,
												GroupLayout.PREFERRED_SIZE)
										.addGap(0, 0, Short.MAX_VALUE))
								.addComponent(panelGraphs, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE,
										Short.MAX_VALUE))
						.addContainerGap()));
		layout.setVerticalGroup(layout.createParallelGroup(
				GroupLayout.Alignment.LEADING)
				.addGroup(layout.createSequentialGroup().addContainerGap().addGroup(layout
						.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup()
								.addComponent(balance, GroupLayout.PREFERRED_SIZE, 52, GroupLayout.PREFERRED_SIZE)
								.addGap(19, 19, 19).addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
										.addGroup(GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
												.addComponent(lIng).addPreferredGap(
														LayoutStyle.ComponentPlacement.RELATED)
												.addComponent(lEgr).addGap(26, 26, 26))
										.addGroup(GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
												.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
														.addComponent(meses.get(0)).addComponent(meses.get(1))
														.addComponent(meses.get(2)).addComponent(meses.get(3))
														.addComponent(meses.get(4)).addComponent(meses.get(5)))
												.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
												.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
														.addGroup(layout.createSequentialGroup()
																.addComponent(ingresos.get(0),
																		GroupLayout.PREFERRED_SIZE,
																		GroupLayout.DEFAULT_SIZE,
																		GroupLayout.PREFERRED_SIZE)
																.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
																.addComponent(egresos.get(0),
																		GroupLayout.PREFERRED_SIZE,
																		GroupLayout.DEFAULT_SIZE,
																		GroupLayout.PREFERRED_SIZE)
																.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
																.addGroup(layout
																		.createParallelGroup(
																				GroupLayout.Alignment.BASELINE)
																		.addComponent(saldos.get(0),
																				GroupLayout.PREFERRED_SIZE,
																				GroupLayout.DEFAULT_SIZE,
																				GroupLayout.PREFERRED_SIZE)
																		.addComponent(lSaldo)))
														.addGroup(layout.createSequentialGroup()
																.addComponent(ingresos.get(1),
																		GroupLayout.PREFERRED_SIZE,
																		GroupLayout.DEFAULT_SIZE,
																		GroupLayout.PREFERRED_SIZE)
																.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
																.addComponent(egresos.get(1),
																		GroupLayout.PREFERRED_SIZE,
																		GroupLayout.DEFAULT_SIZE,
																		GroupLayout.PREFERRED_SIZE)
																.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
																.addComponent(saldos.get(1), GroupLayout.PREFERRED_SIZE,
																		GroupLayout.DEFAULT_SIZE,
																		GroupLayout.PREFERRED_SIZE))
														.addGroup(layout.createSequentialGroup()
																.addComponent(ingresos.get(2),
																		GroupLayout.PREFERRED_SIZE,
																		GroupLayout.DEFAULT_SIZE,
																		GroupLayout.PREFERRED_SIZE)
																.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
																.addComponent(egresos.get(2),
																		GroupLayout.PREFERRED_SIZE,
																		GroupLayout.DEFAULT_SIZE,
																		GroupLayout.PREFERRED_SIZE)
																.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
																.addComponent(saldos.get(2), GroupLayout.PREFERRED_SIZE,
																		GroupLayout.DEFAULT_SIZE,
																		GroupLayout.PREFERRED_SIZE))
														.addGroup(layout.createSequentialGroup()
																.addComponent(ingresos.get(3),
																		GroupLayout.PREFERRED_SIZE,
																		GroupLayout.DEFAULT_SIZE,
																		GroupLayout.PREFERRED_SIZE)
																.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
																.addComponent(egresos.get(3),
																		GroupLayout.PREFERRED_SIZE,
																		GroupLayout.DEFAULT_SIZE,
																		GroupLayout.PREFERRED_SIZE)
																.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
																.addComponent(saldos.get(3), GroupLayout.PREFERRED_SIZE,
																		GroupLayout.DEFAULT_SIZE,
																		GroupLayout.PREFERRED_SIZE))
														.addGroup(layout.createSequentialGroup().addGroup(layout
																.createParallelGroup(GroupLayout.Alignment.BASELINE)
																.addComponent(ingresos.get(4),
																		GroupLayout.PREFERRED_SIZE,
																		GroupLayout.DEFAULT_SIZE,
																		GroupLayout.PREFERRED_SIZE)
																.addComponent(ingresos.get(5),
																		GroupLayout.PREFERRED_SIZE,
																		GroupLayout.DEFAULT_SIZE,
																		GroupLayout.PREFERRED_SIZE))
																.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
																.addGroup(layout
																		.createParallelGroup(
																				GroupLayout.Alignment.BASELINE)
																		.addComponent(egresos.get(4),
																				GroupLayout.PREFERRED_SIZE,
																				GroupLayout.DEFAULT_SIZE,
																				GroupLayout.PREFERRED_SIZE)
																		.addComponent(egresos.get(5),
																				GroupLayout.PREFERRED_SIZE,
																				GroupLayout.DEFAULT_SIZE,
																				GroupLayout.PREFERRED_SIZE))
																.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
																.addComponent(saldos.get(4), GroupLayout.PREFERRED_SIZE,
																		GroupLayout.DEFAULT_SIZE,
																		GroupLayout.PREFERRED_SIZE))
														.addGroup(layout.createSequentialGroup().addGap(52, 52, 52)
																.addComponent(saldos.get(5), GroupLayout.PREFERRED_SIZE,
																		GroupLayout.DEFAULT_SIZE,
																		GroupLayout.PREFERRED_SIZE)))))
								.addGap(0, 0, Short.MAX_VALUE))
						.addComponent(panelGraphs, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
						.addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
						.addGroup(
								layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
										.addComponent(boxGraph, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
												GroupLayout.PREFERRED_SIZE)
										.addComponent(selectGraph))
						.addGap(19, 19, 19)));

	}

	/**
	 * Accion que se realiza al seleccionar un item en el JComboBox. Cambiando
	 * el grafico respecto a lo que se seleccione.
	 */

	private void comboActionPerformed(ActionEvent evt) {

		CardLayout cardLayout = (CardLayout) panelGraphs.getLayout();
		cardLayout.show(panelGraphs, (String) boxGraph.getSelectedItem());

	}

	/**
	 * Inicia los TextFields y Labels en el panel asignandole todos los datos
	 * esperables para mas tarde poder asignarle sus datos.
	 */

	public void iniciarTextFieldYLabel() {

		ingresos = new ArrayList<JTextField>();
		egresos = new ArrayList<JTextField>();
		saldos = new ArrayList<JTextField>();
		meses = new ArrayList<JLabel>();

		for (int x = 0; x < 6; x++) {

			ingresos.add(new JTextField());
			egresos.add(new JTextField());
			saldos.add(new JTextField());
			ingresos.get(x).setBackground(new Color(178, 223, 219));
			ingresos.get(x).setEditable(false);
			egresos.get(x).setBackground(new Color(178, 223, 219));
			egresos.get(x).setEditable(false);
			saldos.get(x).setBackground(new Color(178, 223, 219));
			saldos.get(x).setEditable(false);
			meses.add(new JLabel());
			meses.get(x).setFont(new Font("Candara", 1, 14)); // NOI18N
			meses.get(x).setForeground(new Color(255, 255, 255));

		}

		hideTextFieldsYLabels();
	}

	/**
	 * Esconde todos los TextFields y Labels, esto para que solamente sean
	 * visibles los que contengan datos
	 */

	private void hideTextFieldsYLabels() {

		borde = ingresos.get(0).getBorder();

		for (int x = 0; x < 6; x++) {

			meses.get(x).setText("");

			ingresos.get(x).setOpaque(false);
			ingresos.get(x).setText("");

			egresos.get(x).setOpaque(false);
			egresos.get(x).setText("");

			saldos.get(x).setOpaque(false);
			saldos.get(x).setText("");

			ingresos.get(x).setBorder(javax.swing.BorderFactory.createEmptyBorder());
			egresos.get(x).setBorder(javax.swing.BorderFactory.createEmptyBorder());
			saldos.get(x).setBorder(javax.swing.BorderFactory.createEmptyBorder());

		}

	}

	/**
	 * Llena el de datos los componentes del panelResumen
	 */

	public void llenarResumen() {

		ControlPrincipal control = new ControlPrincipal(usuario);

		hideTextFieldsYLabels();
		actualizarGraphDoc();
		actualizarGraphMes();

		String[][] resumen = control.resumenMes();

		if (resumen[0][0] != null) {

			for (int x = resumen[0].length - 1, z = 0; x > resumen[0].length - 7 && x >= 0; x--, z++) {

				ingresos.get(z).setText(resumen[2][x]);
				ingresos.get(z).setBorder(borde);
				ingresos.get(z).setOpaque(true);

				egresos.get(z).setText(resumen[3][x]);
				egresos.get(z).setBorder(borde);
				egresos.get(z).setOpaque(true);

				saldos.get(z).setText(resumen[1][x]);
				saldos.get(z).setBorder(borde);
				saldos.get(z).setOpaque(true);

				if (resumen[0][x].matches("[0-9]{4}-01")) {

					meses.get(z).setText("Enero");

				} else if (resumen[0][x].matches("[0-9]{4}-02")) {

					meses.get(z).setText("Febrero");

				} else if (resumen[0][x].matches("[0-9]{4}-03")) {

					meses.get(z).setText("Marzo");

				} else if (resumen[0][x].matches("[0-9]{4}-04")) {

					meses.get(z).setText("Abril");

				} else if (resumen[0][x].matches("[0-9]{4}-05")) {

					meses.get(z).setText("Mayo");

				} else if (resumen[0][x].matches("[0-9]{4}-06")) {

					meses.get(z).setText("Junio");

				} else if (resumen[0][x].matches("[0-9]{4}-07")) {

					meses.get(z).setText("Julio");

				} else if (resumen[0][x].matches("[0-9]{4}-08")) {

					meses.get(z).setText("Agosto");

				} else if (resumen[0][x].matches("[0-9]{4}-09")) {

					meses.get(z).setText("Septiembre");

				} else if (resumen[0][x].matches("[0-9]{4}-10")) {

					meses.get(z).setText("Octubre");

				} else if (resumen[0][x].matches("[0-9]{4}-11")) {

					meses.get(z).setText("Noviembre");

				} else if (resumen[0][x].matches("[0-9]{4}-12")) {

					meses.get(z).setText("Diciembre");

				}
			}

		}

	}

	/**
	 * Crea el Grafico del mes, tomando los datos del ControlPrincipal
	 * 
	 * @return Un ChartPanel que contiene el grafico.
	 */

	private ChartPanel crearGraphMes() {

		ControlPrincipal control = new ControlPrincipal(usuario);

		String[][] resumen = control.resumenMes();

		dataSetMes = new DefaultCategoryDataset();

		JFreeChart chart = ChartFactory.createBarChart("Resumen Mensual", "Mes", "Saldo", dataSetMes,
				PlotOrientation.VERTICAL, false, true, false);

		CategoryPlot plot = chart.getCategoryPlot();
		BarRenderer renderer = (BarRenderer) plot.getRenderer();
		ValueAxis axis = plot.getRangeAxis();
		axis.setTickLabelPaint(new Color(0, 0, 0));
		CategoryAxis domain = plot.getDomainAxis();
		domain.setTickLabelPaint(new Color(0, 0, 0));
		renderer.setGradientPaintTransformer(null);
		renderer.setBarPainter(new StandardBarPainter());
		plot.setBackgroundPaint(new Color(0, 103, 103));
		renderer.setSeriesPaint(0, new Color(0, 205, 205));
		chart.setBackgroundPaint(new Color(0, 128, 128));

		ChartPanel graph = new ChartPanel(chart);

		return graph;

	}

	/**
	 * Crea el Grafico del documento, tomando los datos del ControlPrincipal
	 * 
	 * @return Un ChartPanel que contiene el grafico.
	 */

	private ChartPanel crearGraphDoc() {

		ControlPrincipal control = new ControlPrincipal(usuario);

		int[] resumen = control.resumenDoc();

		dataSetDoc = new DefaultCategoryDataset();
		JFreeChart chart = ChartFactory.createBarChart("Resumen por Documentos", "Documento", "Saldo", dataSetDoc,
				PlotOrientation.VERTICAL, false, true, false);

		CategoryPlot plot = chart.getCategoryPlot();
		BarRenderer renderer = (BarRenderer) plot.getRenderer();
		ValueAxis axis = plot.getRangeAxis();
		axis.setTickLabelPaint(new Color(0, 0, 0));
		CategoryAxis domain = plot.getDomainAxis();
		domain.setTickLabelPaint(new Color(0, 0, 0));
		renderer.setGradientPaintTransformer(null);
		renderer.setBarPainter(new StandardBarPainter());
		plot.setBackgroundPaint(new Color(0, 103, 103));
		renderer.setSeriesPaint(0, new Color(0, 205, 205));
		chart.setBackgroundPaint(new Color(0, 128, 128));

		ChartPanel graph = new ChartPanel(chart);

		return graph;
	}

	/**
	 * Actualiza el grafico mes asignandole nuevamente los datos al dataset del
	 * grafico
	 */

	private void actualizarGraphMes() {

		dataSetMes.clear();

		ControlPrincipal control = new ControlPrincipal(usuario);
		String[][] resumen = control.resumenMes();

		if (resumen[0][0] != null) {

			for (int x = 0; x < resumen[0].length; x++) {

				dataSetMes.setValue(Integer.parseInt(resumen[1][x]), "Saldo", resumen[0][x]);
			}

		}

	}

	/**
	 * Actualiza el grafico documento asignandole nuevamente los datos al
	 * dataset del grafico
	 */

	private void actualizarGraphDoc() {

		ControlPrincipal control = new ControlPrincipal(usuario);

		dataSetDoc.clear();

		int[] resumen = control.resumenDoc();

		dataSetDoc.setValue(resumen[0], "Saldo", "Efectivo");
		dataSetDoc.setValue(resumen[1], "Saldo", "Transferencia");
		dataSetDoc.setValue(resumen[2], "Saldo", "Credito");

	}
}
