List of usage examples for org.jfree.chart JFreeChart getCategoryPlot
public CategoryPlot getCategoryPlot()
From source file:my.estadistico.Grafica.java
private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton6ActionPerformed // TODO add your handling code here: try {// w ww .j a va 2s . c o m this.datos();//Obtiene los datos JFreeChart chart = ChartFactory.createLineChart3D(null, null, null, dataset); CategoryPlot catPlot = chart.getCategoryPlot(); catPlot.setRangeGridlinePaint(Color.BLACK); this.mostrar(chart); } catch (Exception e) { JOptionPane.showMessageDialog(rootPane, "FAVOR DE INGRESAR DATOS"); } }
From source file:net.sf.mzmine.chartbasics.gestures.ChartGestureEvent.java
/** * True if axis is vertical, false if horizontal, null if there was an error * /*w w w.ja va2s . co m*/ * @param axis * @return */ public Boolean isVerticalAxis(ValueAxis axis) { if (axis == null) return null; JFreeChart chart = getChart(); PlotOrientation orient = PlotOrientation.HORIZONTAL; if (chart.getXYPlot() != null) orient = chart.getXYPlot().getOrientation(); else if (chart.getCategoryPlot() != null) orient = chart.getCategoryPlot().getOrientation(); // error if (orient == null) return null; Entity entity = this.getGesture().getEntity(); double start = 0; // horizontal if ((entity.equals(Entity.DOMAIN_AXIS) && orient.equals(PlotOrientation.VERTICAL)) || (entity.equals(Entity.RANGE_AXIS) && orient.equals(PlotOrientation.HORIZONTAL))) { return false; } // vertical else if ((entity.equals(Entity.RANGE_AXIS) && orient.equals(PlotOrientation.VERTICAL)) || (entity.equals(Entity.DOMAIN_AXIS) && orient.equals(PlotOrientation.HORIZONTAL))) { return true; } // error return null; }
From source file:br.com.OCTur.view.ContigenteController.java
@FXML private void eCarregarGraficosActionEvent(ActionEvent actionEvent) { DefaultCategoryDataset dcdDados = new DefaultCategoryDataset(); if (rbAeroporto.isSelected()) { if (inicio >= aeroportos.size() && !aeroportos.isEmpty()) { inicio = aeroportos.size() - 10; }//from w w w . j a v a2 s.co m for (EntidadeGrafico<Aeroporto> entidadegrafico : aeroportos.subList(inicio, inicio + 10 > aeroportos.size() ? aeroportos.size() : inicio + 10)) { if (entidadegrafico.getValue() >= MAX) { dcdDados.setValue(entidadegrafico.getValue(), "Pessoas/Maior", entidadegrafico.toString()); } else if (entidadegrafico.getValue() <= MIN) { dcdDados.setValue(entidadegrafico.getValue(), "Pessoas/Menor", entidadegrafico.toString()); } else { dcdDados.setValue(entidadegrafico.getValue(), "Pessoas", entidadegrafico.toString()); } } } else if (rbCompanhia.isSelected()) { if (inicio >= companhias.size() && !companhias.isEmpty()) { inicio = companhias.size() - 10; } for (EntidadeGrafico<Companhia> entidadegrafico : companhias.subList(inicio, inicio + 10 > companhias.size() ? companhias.size() : inicio + 10)) { if (entidadegrafico.getValue() >= MAX) { dcdDados.setValue(entidadegrafico.getValue(), "Pessoas/Maior", entidadegrafico.toString()); } else if (entidadegrafico.getValue() <= MIN) { dcdDados.setValue(entidadegrafico.getValue(), "Pessoas/Menor", entidadegrafico.toString()); } else { dcdDados.setValue(entidadegrafico.getValue(), "Pessoas", entidadegrafico.toString()); } } } else { if (inicio >= aviaos.size() && !aviaos.isEmpty()) { inicio = aviaos.size() - 10; } for (EntidadeGrafico<Aviao> entidadegrafico : aviaos.subList(inicio, inicio + 10 > aviaos.size() ? aviaos.size() : inicio + 10)) { if (entidadegrafico.getValue() >= MAX) { dcdDados.setValue(entidadegrafico.getValue(), "Pessoas/Maior", entidadegrafico.toString()); } else if (entidadegrafico.getValue() <= MIN) { dcdDados.setValue(entidadegrafico.getValue(), "Pessoas/Menor", entidadegrafico.toString()); } else { dcdDados.setValue(entidadegrafico.getValue(), "Pessoas", entidadegrafico.toString()); } } } JFreeChart jFreeChart = ChartFactory.createBarChart("", "", "", dcdDados, PlotOrientation.VERTICAL, false, false, false); if (rbAviao.isSelected()) { jFreeChart.getCategoryPlot().getRangeAxis().setRange(new Range(0, 100)); jFreeChart.getCategoryPlot().getRenderer().setBaseItemLabelGenerator( new StandardCategoryItemLabelGenerator("{2}%", NumberFormat.getInstance())); jFreeChart.getCategoryPlot().getRenderer().setBaseItemLabelsVisible(true); } else { jFreeChart.getCategoryPlot().getRenderer().setBaseItemLabelGenerator( new StandardCategoryItemLabelGenerator("{2}", NumberFormat.getInstance())); jFreeChart.getCategoryPlot().getRenderer().setBaseItemLabelsVisible(true); } ChartPanel chartPanel = new ChartPanel(jFreeChart); snGraficos.setContent(chartPanel); snGraficos.getContent().repaint(); }
From source file:gui.TraitViewerDialog.java
@SuppressWarnings("rawtypes") private ChartPanel getChart(int selectedRow) { ArrayList<Float> data = new ArrayList<Float>(); for (float[] row : tFile.getRows()) { if (row[selectedRow + 1] != (float) -99.0) { data.add(row[selectedRow + 1]); }// w ww . j a v a 2s. com } BoxAndWhiskerItem a = BoxAndWhiskerCalculator.calculateBoxAndWhiskerStatistics(data); java.util.List l = new ArrayList(0); a = new BoxAndWhiskerItem(a.getMean(), a.getMedian(), a.getQ1(), a.getQ3(), a.getMinRegularValue(), a.getMaxRegularValue(), a.getMinRegularValue(), a.getMaxRegularValue(), l); traitstats.setText(showBoxAndWhiskerItem(a)); DefaultBoxAndWhiskerCategoryDataset ds2 = new DefaultBoxAndWhiskerCategoryDataset(); ds2.add(a, (Comparable) 1, (Comparable) 1); JFreeChart chart = ChartFactory.createBoxAndWhiskerChart(null, null, null, ds2, false); chart.removeLegend(); // XYPlot plot = chart.getXYPlot(); CategoryPlot plot = chart.getCategoryPlot(); plot.getDomainAxis().setVisible(false); BoxAndWhiskerRenderer b = (BoxAndWhiskerRenderer) plot.getRenderer(); // b.setFillBox(false); b.setSeriesPaint(0, new Color(236, 55, 169)); b.setSeriesOutlinePaint(1, new Color(131, 79, 112)); b.setBaseOutlineStroke(new BasicStroke(1.0f)); // b.get b.setWhiskerWidth(0.8); b.setBaseOutlinePaint(new Color(84, 144, 201)); b.setDefaultEntityRadius(2); b.setMaximumBarWidth(0.18); ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPopupMenu(null); return chartPanel; }
From source file:josejamilena.pfc.analizador.GraficoPorScript.java
public GraficoPorScript(final String hostCliente, final String hostSgbd) throws ClassNotFoundException, SQLException { Map<String, String> res = new TreeMap<String, String>(); DefaultCategoryDataset dataset = new DefaultCategoryDataset(); Statement stmt = null;// ww w . ja v a 2 s . c o m ResultSet rs = null; String consulta = "select tiempo, fecha from estadisticas where host_cliente=\'" + hostCliente + "\' and host_sgbd=\'" + hostSgbd + "\'"; stmt = App.conn.createStatement(); rs = stmt.executeQuery(consulta); while (rs.next()) { res.put(rs.getString(2), rs.getString(1)); } rs.close(); stmt.close(); Iterator it = res.entrySet().iterator(); while (it.hasNext()) { Map.Entry pairs = (Map.Entry) it.next(); dataset.setValue(Double.parseDouble(pairs.getValue().toString()), hostCliente, pairs.getKey().toString()); } JFreeChart chart = ChartFactory.createBarChart(hostCliente + " / " + hostSgbd, // chart title "Hora", // domain axis label "Duracin (milisegundos)", // range axis label dataset, // data PlotOrientation.HORIZONTAL, false, // include legend true, false); CategoryPlot plot = chart.getCategoryPlot(); chart.setBackgroundPaint(Color.white); plot.setOutlinePaint(Color.black); ChartPanel chartPanel = new ChartPanel(chart); JScrollPane scrollPane = new JScrollPane(); scrollPane.getViewport().add((new JPanel()).add(chartPanel)); setContentPane(scrollPane); }
From source file:org.bench4Q.console.ui.section.E_ErrorSection.java
private JPanel printErrorPic() throws IOException { CategoryDataset dataset = getDataSet(); JFreeChart chart = ChartFactory.createBarChart3D("Error", "Error type", "Error number", dataset, PlotOrientation.VERTICAL, true, true, true); CategoryPlot plot = chart.getCategoryPlot(); org.jfree.chart.axis.CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setLowerMargin(0.1);//from w w w . j a v a2s. com domainAxis.setUpperMargin(0.1); domainAxis.setCategoryLabelPositionOffset(10); domainAxis.setCategoryMargin(0.2); domainAxis.setCategoryLabelPositionOffset(10); 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:virgil.meanback.HistoryInfo.java
public void printChart(Stock stock, List<String[]> list, int days) throws Exception { //?/*from w w w. j a v a2 s . c o m*/ StandardChartTheme standardChartTheme = new StandardChartTheme("CN"); // standardChartTheme.setExtraLargeFont(new Font("", Font.BOLD, 20)); // standardChartTheme.setRegularFont(new Font("", Font.BOLD, 12)); //? standardChartTheme.setLargeFont(new Font("", Font.BOLD, 18)); //? ChartFactory.setChartTheme(standardChartTheme); DefaultCategoryDataset dataSet = new DefaultCategoryDataset(); for (int i = list.size() - 1; i >= 0; i--) { String[] s = (String[]) list.get(i); dataSet.addValue(Double.parseDouble(s[1]), days + "", s[0]); dataSet.addValue(Double.parseDouble(stock.getList().get(i).getClose()), "", s[0]); float sub = Float.parseFloat(s[2]); float error = Float.parseFloat(s[3]); if (sub > error * 2) { dataSet.addValue(Double.parseDouble(stock.getList().get(i).getClose()), "??", s[0]); } } //?????Legend //???? //??URL JFreeChart chart = ChartFactory.createLineChart( stock.getName() + "(" + stock.getCode() + ") ", "", "", dataSet, PlotOrientation.VERTICAL, true, true, false); CategoryPlot cp = chart.getCategoryPlot(); cp.setBackgroundPaint(ChartColor.WHITE); // CategoryAxis categoryAxis = cp.getDomainAxis(); // Lable 90 Font labelFont = new Font("SansSerif", Font.TRUETYPE_FONT, 10); categoryAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_90); categoryAxis.setTickLabelFont(labelFont);//X?? ValueAxis yAxis = cp.getRangeAxis(); yAxis.setAutoRange(true); double[] d = getAxiasThresold(stock, list); yAxis.setLowerBound(d[0] - 0.15); yAxis.setUpperBound(d[1] + 0.15); LineAndShapeRenderer lasp = (LineAndShapeRenderer) cp.getRenderer(); lasp.setBaseFillPaint(ChartColor.RED); lasp.setDrawOutlines(true); lasp.setSeriesShape(0, new java.awt.geom.Ellipse2D.Double(-5D, -5D, 10D, 10D)); LineAndShapeRenderer renderer = (LineAndShapeRenderer) cp.getRenderer(1);//? DecimalFormat decimalformat1 = new DecimalFormat("##.##");//??? renderer.setItemLabelGenerator(new StandardCategoryItemLabelGenerator("{2}", decimalformat1)); //???? renderer.setItemLabelsVisible(true);// renderer.setBaseItemLabelsVisible(true);// //????? renderer.setShapesFilled(Boolean.TRUE);//?? renderer.setShapesVisible(true);//? ChartFrame chartFrame = new ChartFrame("??", chart, true); //chart?JavaChartFramejavaJframe???? chartFrame.pack(); //?? chartFrame.setVisible(true);//??? }
From source file:api.window.Histogram.java
private JFreeChart createChart(DefaultCategoryDataset dataset) { JFreeChart jfreechart = ChartFactory.createBarChart(null, null, null, dataset, PlotOrientation.VERTICAL, false, false, false);// w ww . ja v a2 s .c om final CategoryPlot plot = jfreechart.getCategoryPlot(); BarRenderer barRenderer = (BarRenderer) plot.getRenderer(); return jfreechart; }
From source file:UserInterface.FinanceRole.DonationsReceivedJPanel.java
private void generateDonationAnalysis() { DefaultCategoryDataset dataSet = new DefaultCategoryDataset(); for (Organization objDonorOrganization : objWorldEnterprise.getObjOrganizationDirectory() .getOrganizationList()) {/* w w w . j av a 2 s . c o m*/ if (objDonorOrganization instanceof DonorOrganization) { for (Person objPerson : objDonorOrganization.getObjPersonDirectory().getPersonList()) { BigDecimal totalAmount = new BigDecimal(0); for (Transaction objTransaction : objPerson.getObjDonorTransactionDirectory() .getTransactionList()) { totalAmount = totalAmount.add(objTransaction.getTransactionBDAmount()); } dataSet.setValue(totalAmount, "Donation", objPerson.getPersonFirstName()); } } } JFreeChart chart = ChartFactory.createBarChart3D("Overview of entire donation", "Donor Name", "Total donation in USD $", dataSet, PlotOrientation.VERTICAL, false, true, false); CategoryPlot plot = chart.getCategoryPlot(); plot.setRangeGridlinePaint(Color.black); ChartPanel myChart = new ChartPanel(chart); donationJPanel.setLayout(new java.awt.BorderLayout()); donationJPanel.add(myChart, BorderLayout.CENTER); donationJPanel.validate(); }
From source file:UserInterface.StoreManager.StoreReportsPanel.java
private void storeKeeperButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_storeKeeperButtonActionPerformed // TODO add your handling code here: ArrayList<Comparison> cmp1 = new ArrayList<>(); int x = 0;/*from w w w. j a v a2 s. c o m*/ for (Organization org : enterprise.getOrganizationDirectory().getOrganizationList()) { if (org instanceof StoreKeeperOrganization) { System.out.println("Hi"); for (UserAccount ua : org.getUserAccountDirectory().getUserAccountList()) { x = 0; for (WorkRequest w : ua.getWorkQueue().getWorkRequestList()) { x++; } Comparison c = new Comparison(ua.getEmployee().getName(), x); cmp1.add(c); } } } Collections.sort(cmp1); DefaultCategoryDataset dataset = new DefaultCategoryDataset(); if (cmp1.size() >= 3) { dataset.setValue(cmp1.get(0).getNumber(), "WorkRequests", cmp1.get(0).getString()); dataset.setValue(cmp1.get(1).getNumber(), "WorkRequests", cmp1.get(1).getString()); dataset.setValue(cmp1.get(2).getNumber(), "WorkRequests", cmp1.get(2).getString()); } else { for (Comparison c : cmp1) { dataset.setValue(c.getNumber(), "WorkRequests", c.getString()); } } JFreeChart chart = ChartFactory.createBarChart("Top StoreKeepers", "Storekeepers", "No of Workrequests Solved", dataset, PlotOrientation.VERTICAL, false, true, false); CategoryPlot p = chart.getCategoryPlot(); p.setRangeGridlinePaint(Color.BLUE); ChartFrame frame = new ChartFrame("StoreKeeper Report", chart); frame.setVisible(true); frame.setSize(600, 400); }