List of usage examples for org.jfree.chart JFreeChart getCategoryPlot
public CategoryPlot getCategoryPlot()
From source file:UserInterface.SupplierRole.ProductReportJPanel.java
private void btnPictorialViewActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnPictorialViewActionPerformed // TODO add your handling code here: DefaultCategoryDataset categoryDataset = new DefaultCategoryDataset(); for (Product product : supplier.getProductCatalog().getProductCatalog()) { categoryDataset.setValue(product.getSoldQuantity(), "Units", product.getProdName()); }/*ww w. j ava2 s . c o m*/ JFreeChart freeChart = ChartFactory.createBarChart("Sales Report", "Product", "Units", categoryDataset, PlotOrientation.VERTICAL, false, true, false); CategoryPlot categoryPlot = freeChart.getCategoryPlot(); categoryPlot.setRangeGridlinePaint(Color.BLACK); ChartFrame cf = new ChartFrame("Sales Report", freeChart); cf.setVisible(true); cf.setSize(450, 300); }
From source file:Controller.Movimientos.ControllerMovimientos.java
@Override public void actionPerformed(ActionEvent e) { switch (Actions.valueOf(e.getActionCommand())) { case btn_home: this.v.pnl_Main.removeAll(); this.v.pnl_Main.add(this.v.SplitPane1, BorderLayout.CENTER); this.v.pnl_Main.setVisible(false); this.v.pnl_Main.setVisible(true); break;//from w w w . java 2 s .c om case btn_ventasMovi: this.v.pnl_contenedorDerechoMovimientos.removeAll(); this.v.pnl_contenedorDerechoMovimientos.add(this.v.pnl_contenedorDerecho, BorderLayout.CENTER); this.v.pnl_contenedorDerechoMovimientos.setVisible(false); this.v.pnl_contenedorDerechoMovimientos.setVisible(true); DefaultCategoryDataset b = new DefaultCategoryDataset(); b.setValue(mm.getRecordEnero(), "Ventas", "Ene"); b.setValue(mm.getRecordFebrero(), "Ventas", "Feb"); b.setValue(mm.getRecordMarzo(), "Ventas", "Mar"); b.setValue(mm.getRecordAbril(), "Ventas", "Abr"); b.setValue(mm.getRecordMayo(), "Ventas", "May"); b.setValue(mm.getRecordJunio(), "Ventas", "Jun"); b.setValue(mm.getRecordJulio(), "Ventas", "Jul"); b.setValue(mm.getRecordAgosto(), "Ventas", "Ago"); b.setValue(mm.getRecordSeptiembre(), "Ventas", "Sep"); b.setValue(mm.getRecordOctubre(), "Ventas", "Oct"); b.setValue(mm.getRecordNoviembre(), "Ventas", "Nov"); b.setValue(mm.getRecordNoviembre(), "Ventas", "Dic"); JFreeChart grafica = ChartFactory.createBarChart("Ventas", "Meses", "Numero de ventas", b, PlotOrientation.VERTICAL, false, true, false); CategoryPlot graficaPlot = grafica.getCategoryPlot(); graficaPlot.setRangeGridlinePaint(Color.BLUE); ChartPanel barPanel = new ChartPanel(grafica); this.v.pnl_mostrarGrafica.removeAll(); this.v.pnl_mostrarGrafica.add(barPanel, BorderLayout.CENTER); this.v.pnl_mostrarGrafica.setVisible(false); this.v.pnl_mostrarGrafica.setVisible(true); mostrarFilechooser(); break; case btn_empleMovi: this.v.pnl_contenedorDerechoMovimientos.removeAll(); this.v.pnl_contenedorDerechoMovimientos.add(this.v.pnl_contenedorDerecho, BorderLayout.CENTER); this.v.pnl_contenedorDerechoMovimientos.setVisible(false); this.v.pnl_contenedorDerechoMovimientos.setVisible(true); DefaultCategoryDataset bE = new DefaultCategoryDataset(); Iterator it; it = mm.getCrews().iterator(); while (it.hasNext()) { Crew c = (Crew) it.next(); System.out.println("" + c.getEmail().toString()); bE.setValue(mm.getConexionesCount(c.getEmail().toString()), c.getEmail().toString(), c.getEmail().toString()); } JFreeChart graficaEmpleado = ChartFactory.createBarChart("Conexiones", "Meses", "Numero de ventas", bE, PlotOrientation.VERTICAL, false, true, false); CategoryPlot graficaPlotEmpleado = graficaEmpleado.getCategoryPlot(); graficaPlotEmpleado.setRangeGridlinePaint(Color.BLUE); ChartPanel barPanelEmpleado = new ChartPanel(graficaEmpleado); this.v.pnl_mostrarGrafica.removeAll(); this.v.pnl_mostrarGrafica.add(barPanelEmpleado, BorderLayout.CENTER); this.v.pnl_mostrarGrafica.setVisible(false); this.v.pnl_mostrarGrafica.setVisible(true); mostrarFilechooser(); break; case btn_productoMovi: this.v.pnl_contenedorDerechoMovimientos.removeAll(); this.v.pnl_contenedorDerechoMovimientos.add(this.v.pnl_contenedorDerecho, BorderLayout.CENTER); this.v.pnl_contenedorDerechoMovimientos.setVisible(false); this.v.pnl_contenedorDerechoMovimientos.setVisible(true); DefaultCategoryDataset bP = new DefaultCategoryDataset(); Iterator itP; itP = mm.getProducts().iterator(); while (itP.hasNext()) { Product p = (Product) itP.next(); System.out.println("" + p.getName()); bP.setValue(mm.getProductCount(p.getName().toString()), p.getName().toString(), p.getName().toString()); } JFreeChart graficaProducto = ChartFactory.createBarChart("Productos Vendidos", "Productos", "Ventas", bP, PlotOrientation.HORIZONTAL, false, true, false); CategoryPlot graficaPlotProducto = graficaProducto.getCategoryPlot(); graficaPlotProducto.setRangeGridlinePaint(Color.BLUE); ChartPanel barPanelProducto = new ChartPanel(graficaProducto); this.v.pnl_mostrarGrafica.removeAll(); this.v.pnl_mostrarGrafica.add(barPanelProducto, BorderLayout.CENTER); this.v.pnl_mostrarGrafica.setVisible(false); this.v.pnl_mostrarGrafica.setVisible(true); mostrarFilechooser(); break; case btn_configMovimientos: break; case btn_abrirFilechooser: break; case btn_informe: this.pdf.generateInforme(); break; } }
From source file:my.estadistico.Grafica.java
private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed try {//from w ww .j ava2 s.c om this.datos();//Obtiene los datos JFreeChart chart = ChartFactory.createLineChart(null, null, null, dataset); //Grafico de linea CategoryPlot catPlot = chart.getCategoryPlot(); catPlot.setRangeGridlinePaint(Color.BLACK); this.mostrar(chart); } catch (Exception e) { JOptionPane.showMessageDialog(rootPane, "FAVOR DE INGRESAR DATOS"); } // TODO add your handling code here: }
From source file:user.CreateChart.java
private ImageIcon barChart(CategoryDataset dataset, String name, String X, String Y) { final JFreeChart chart = ChartFactory.createBarChart(name, // chart title X, // domain axis label Y, // range axis label dataset, // data PlotOrientation.VERTICAL, // orientation true, // include legend true, // tooltips? false // URLs? );/*from w ww . j av a 2 s . c o m*/ final CategoryPlot plot = chart.getCategoryPlot(); final org.jfree.chart.axis.NumberAxis rangeAxis = (org.jfree.chart.axis.NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(org.jfree.chart.axis.NumberAxis.createIntegerTickUnits()); ImageIcon ii = new ImageIcon(chart.createBufferedImage(592, 500)); return ii; }
From source file:org.bench4Q.console.ui.section.S_LengthSection.java
/** * @return/* w w w. j av a 2s .co m*/ * @throws IOException */ public JPanel drawSessionPic() throws IOException { CategoryDataset dataset = getDataSet(); JFreeChart chart = ChartFactory.createBarChart3D("Session", "Session type", "Session number", dataset, PlotOrientation.VERTICAL, true, true, true); CategoryPlot plot = chart.getCategoryPlot(); org.jfree.chart.axis.CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setLowerMargin(0.1); domainAxis.setUpperMargin(0.1); domainAxis.setCategoryLabelPositionOffset(10); domainAxis.setCategoryMargin(0.2); org.jfree.chart.axis.ValueAxis rangeAxis = plot.getRangeAxis(); rangeAxis.setUpperMargin(0.1); org.jfree.chart.renderer.category.BarRenderer3D renderer; renderer = new org.jfree.chart.renderer.category.BarRenderer3D(); renderer.setBaseOutlinePaint(Color.red); renderer.setSeriesPaint(0, new Color(0, 255, 255)); renderer.setSeriesOutlinePaint(0, Color.BLACK); renderer.setSeriesPaint(1, new Color(0, 255, 0)); renderer.setSeriesOutlinePaint(1, Color.red); renderer.setItemMargin(0.1); renderer.setItemLabelGenerator(new StandardCategoryItemLabelGenerator()); renderer.setItemLabelFont(new Font("", Font.BOLD, 12)); renderer.setItemLabelPaint(Color.black); renderer.setItemLabelsVisible(true); plot.setRenderer(renderer); plot.setDomainAxisLocation(AxisLocation.BOTTOM_OR_LEFT); plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT); plot.setBackgroundPaint(Color.WHITE); return new ChartPanel(chart); }
From source file:simz1.StackedBarChart.java
public void ShorteatsGraph() { DefaultCategoryDataset sedata = new DefaultCategoryDataset(); sedata.setValue(se1, "sales", d1); sedata.setValue(se2, "sales", d2); sedata.setValue(se3, "sales", d3); sedata.setValue(se4, "sales", d4); sedata.setValue(se5, "sales", d5); sedata.setValue(se6, "sales", d6); sedata.setValue(se7, "sales", d7); JFreeChart chart1 = ChartFactory.createLineChart("Sales of Shorteats last week", "Date", "sales", sedata, PlotOrientation.VERTICAL, false, true, false); CategoryPlot c1 = chart1.getCategoryPlot(); c1.setBackgroundPaint(Color.white); c1.getRenderer().setSeriesPaint(0, Color.RED); //c1.setRangeGridlinePaint(Color.red); ChartPanel c1Panel = new ChartPanel(chart1); mhp.chartPanel.removeAll();//from w w w . j av a 2 s. co m mhp.chartPanel.add(c1Panel); }
From source file:fi.smaa.jsmaa.gui.SMAATRIGUIFactory.java
@Override public ViewBuilder buildView(Object o) { if (o instanceof Alternative && smaaModel.getCategories().contains(o)) { return new ViewBuilder() { @Override/*ww w. j a v a 2 s . co m*/ public JComponent buildPanel() { return new JPanel(); } }; } else if (o == treeModel.getModelNode()) { return new TechnicalParameterView(smaaModel); } else if (o == treeModel.getCatAccNode()) { final JFreeChart chart = ChartFactory.createStackedBarChart("", "Alternative", "Category Acceptability", categoryAcceptabilityDataset, PlotOrientation.VERTICAL, true, true, false); chart.getCategoryPlot().getRangeAxis().setUpperBound(1.0); ResultsTable table = new ResultsTable(categoryAcceptabilityTM); table.setAutoCreateRowSorter(true); table.setDefaultRenderer(Object.class, new ResultsCellColorRenderer(1.0)); return new ViewWithHeader("Category acceptability indices", new ResultsView(parent, table, chart, FileNames.ICON_SCRIPT)); } else if (o == treeModel.getCategoriesNode()) { return new ViewWithHeader("Categories (in ascending order, top = worst)", new AlternativeInfoView(smaaModel.getCategories())); } else { return super.buildView(o); } }
From source file:simz1.StackedBarChart.java
public void BreadGraph() { DefaultCategoryDataset bidata = new DefaultCategoryDataset(); bidata.setValue(bi1, "sales", d1); bidata.setValue(bi2, "sales", d2); bidata.setValue(bi3, "sales", d3); bidata.setValue(bi4, "sales", d4); bidata.setValue(bi5, "sales", d5); bidata.setValue(bi6, "sales", d6); bidata.setValue(bi7, "sales", d7); JFreeChart chart3 = ChartFactory.createLineChart("Sales of Bread Items last week", "Date", "sales", bidata, PlotOrientation.VERTICAL, false, true, false); CategoryPlot c3 = chart3.getCategoryPlot(); c3.setBackgroundPaint(Color.white); c3.getRenderer().setSeriesPaint(0, Color.GREEN); //c3.setRangeGridlinePaint(Color.green); ChartPanel c3Panel = new ChartPanel(chart3); mhp.chartPanel.removeAll();//from w w w . j a v a2 s.c o m mhp.chartPanel.add(c3Panel); }
From source file:simz1.StackedBarChart.java
public void SweetsGraph() { DefaultCategoryDataset sidata = new DefaultCategoryDataset(); sidata.setValue(si1, "sales", d1); sidata.setValue(si2, "sales", d2); sidata.setValue(si3, "sales", d3); sidata.setValue(si4, "sales", d4); sidata.setValue(si5, "sales", d5); sidata.setValue(si6, "sales", d6); sidata.setValue(si7, "sales", d7); JFreeChart chart5 = ChartFactory.createLineChart("Sales of Sweet items last week", "Date", "sales", sidata, PlotOrientation.VERTICAL, false, true, false); CategoryPlot c5 = chart5.getCategoryPlot(); c5.setBackgroundPaint(Color.lightGray); c5.getRenderer().setSeriesPaint(0, Color.PINK); //c5.setRangeGridlinePaint(Color.pink); ChartPanel c5Panel = new ChartPanel(chart5); mhp.chartPanel.removeAll();//ww w . jav a 2s. c o m mhp.chartPanel.add(c5Panel); }
From source file:userInterface.CustomerWorkArea.ViewChartJPanel.java
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed DefaultCategoryDataset dataSet = new DefaultCategoryDataset(); for (CarInspection carList : userAccount.getPerson().getCarInspectionHistory().getCarInspectionHistory()) { dataSet.setValue(carList.getBrakingSys(), "Brakes", carList.getTimestamp()); }/*w ww .j a v a 2 s .c om*/ JFreeChart chart = ChartFactory.createBarChart("Brakes", "Timestamp", "Brakes", dataSet, PlotOrientation.HORIZONTAL.VERTICAL, false, true, false); CategoryPlot p = chart.getCategoryPlot(); p.setRangeGridlinePaint(Color.BLACK); ChartFrame frame = new ChartFrame("BRAKES GRAPH", chart); frame.setVisible(true); frame.setSize(600, 600); // TODO add your handling code here: }