List of usage examples for org.jfree.data.category DefaultCategoryDataset DefaultCategoryDataset
public DefaultCategoryDataset()
From source file:kata.pkg3.HistogramDisplay.java
private DefaultCategoryDataset createDataset() { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); for (String key : histograma.keySet()) { dataset.addValue(histograma.get(key), "", key); }/*from w ww . j ava 2 s .c om*/ return dataset; }
From source file:javaapplication2.BarChart3D.java
private DefaultCategoryDataset createDataset() throws ClassNotFoundException, SQLException { m.calculoNotas();/*from w w w . j a v a2 s. c o m*/ DefaultCategoryDataset dataset = new DefaultCategoryDataset(); dataset.addValue(m.getnota1(), "Nota 1", "Nota 1"); dataset.addValue(m.getnota2(), "Nota 2", "Nota 2"); dataset.addValue(m.getnota3(), "Nota 3", "Nota 3"); dataset.addValue(m.getnota4(), "Nota 4", "Nota 4"); dataset.addValue(m.getnota5(), "Nota 5", "Nota 5"); return dataset; }
From source file:presentationLayer.PredictionGraph.java
private DefaultCategoryDataset createDataset() { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); SellsDAO dao = new SellsJDBC(); ItemService is = new ItemServiceImplementation(); System.out.println(id);// w w w . ja v a 2 s.c om double price = is.getPrice(id); try { Sells[] sells = dao.read(); int count = 1; for (int i = 0; i < sells.length; i++) { if (sells[i].getItem_id() == id) { double profit = price * sells[i].getSell_num(); String str = String.valueOf(count++); dataset.addValue(profit, "Orders", str); } } dataset.addValue(y1, "Orders", "(Predicated)"); } catch (ClassNotFoundException ex) { Logger.getLogger(PredictionGraph.class.getName()).log(Level.SEVERE, null, ex); } catch (SQLException ex) { Logger.getLogger(PredictionGraph.class.getName()).log(Level.SEVERE, null, ex); } return dataset; }
From source file:Visao.grafico.Grafico.java
private CategoryDataset createDataset() { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); //dataset.addValue(1000.0,"01/2012","Ms/Ano"); for (int i = 0; i < ControlePrincipal.valor_grafico.length; i++) { dataset.addValue(ControlePrincipal.valor_grafico[i], ControlePrincipal.info_grafico[i], ControlePrincipal.tipo_grafico); }// w w w . j a v a 2s . co m return dataset; }
From source file:ANNFileDetect.GraphingClass.java
public JFreeChart chartOutcome(HashMap hm) { JFreeChart jf = null;/* www . ja va 2 s . co m*/ DefaultCategoryDataset dc = new DefaultCategoryDataset(); String xax = "File Type"; Iterator it = hm.entrySet().iterator(); while (it.hasNext()) { Map.Entry pair = (Map.Entry) it.next(); dc.addValue((Double) pair.getValue(), xax, pair.getKey().toString()); } jf = ChartFactory.createBarChart3D("File detection results", "File type", "Score", (CategoryDataset) dc, PlotOrientation.VERTICAL, true, true, true); return jf; }
From source file:vista.montecarlo.GraficoEvolutivo.java
private DefaultCategoryDataset createDataset() { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); for (int politica = 0; politica < costosPromedio.length; politica++) { for (int dia = 0; dia < costosPromedio[politica].length; dia++) { switch (politica) { case 0: { dataset.addValue(costosPromedio[politica][dia], "Politica A", "" + dia); break; }/*from ww w. ja v a 2 s . c o m*/ case 1: { dataset.addValue(costosPromedio[politica][dia], "Politica B", "" + dia); break; } case 2: { dataset.addValue(costosPromedio[politica][dia], "Politica Alternativa", "" + dia); break; } } } } // dataset.addValue( 15 , "schools" , "1970" ); // dataset.addValue( 30 , "schools" , "1980" ); // dataset.addValue( 60 , "schools" , "1990" ); // dataset.addValue( 120 , "schools" , "2000" ); // dataset.addValue( 240 , "schools" , "2010" ); // dataset.addValue( 300 , "schools" , "2014" ); // dataset.addValue( 15 , "schools2" , "-5" ); // dataset.addValue( 30 , "schools2" , "19" ); // dataset.addValue( 60 , "schools2" , "199" ); // dataset.addValue( 120 , "schools2" , "200" ); // dataset.addValue( 240 , "schools2" , "201" ); // dataset.addValue( 300 , "schools2" , "204" ); return dataset; }
From source file:com.crunchify.jsp.servlet.BarServlet.java
public JFreeChart getChart() { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); dataset.addValue(15, "1", "451"); dataset.addValue(12, "1", "851"); dataset.addValue(10, "2", "362"); dataset.addValue(5, "2", "142"); JFreeChart chart = ChartFactory.createBarChart("Bar Chart Demo 3", // chart title "Category", // domain axis label "Value", // range axis label dataset, // data PlotOrientation.VERTICAL, // the plot orientation false, // include legend true, false);//from w w w . j a va 2s . com chart.setBackgroundPaint(Color.lightGray); // get a reference to the plot for further customisation... CategoryPlot plot = chart.getCategoryPlot(); plot.setNoDataMessage("NO DATA!"); CategoryItemRenderer renderer = new CustomRenderer(new Paint[] { Color.red, Color.blue, Color.green, Color.yellow, Color.orange, Color.cyan, Color.magenta, Color.blue }); renderer.setItemLabelsVisible(true); ItemLabelPosition p = new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.CENTER, TextAnchor.CENTER, 45.0); renderer.setPositiveItemLabelPosition(p); plot.setRenderer(renderer); // change the margin at the top of the range axis... ValueAxis rangeAxis = plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); rangeAxis.setLowerMargin(0.15); rangeAxis.setUpperMargin(0.15); return chart; }
From source file:spec.reporter.Utils.java
public static void createBmResultGraph(BenchmarkRecord record) { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); String iterName = ""; double max = 0; double min = Long.MAX_VALUE; for (int i = 0; i < record.iterRecords.size(); i++) { BenchmarkRecord.IterationRecord iterRecord = (BenchmarkRecord.IterationRecord) record.iterRecords .get(i);/*from www . ja v a 2 s. c o m*/ String shortName = iterRecord.iterName.replaceFirst("ation", ""); if (iterRecord.score > max) { max = iterRecord.score; iterName = shortName; } if (iterRecord.score < min) { min = iterRecord.score; } dataset.addValue(iterRecord.score, " ", shortName); } JFreeChart chart = ChartFactory.createLineChart(" ", "iterations", Constants.WORKLOAD_METRIC, dataset, PlotOrientation.VERTICAL, false, true, false); CategoryPlot plot = chart.getCategoryPlot(); plot.setBackgroundPaint(new Color(201, 222, 254)); plot.setRangeGridlinePaint(Color.WHITE); if (record.isValidRun() && min != Long.MAX_VALUE) { plot.getRangeAxis().setRange(min - 10, max + 10); } else { plot.getRangeAxis().setRange(0, max + 10); } ValueMarker vm = new ValueMarker(record.maxScore); vm.setLabel(Utils.df.format(record.maxScore)); vm.setLabelAnchor(RectangleAnchor.TOP_LEFT); vm.setLabelTextAnchor(TextAnchor.HALF_ASCENT_LEFT); plot.addRangeMarker(vm); CategoryMarker marker = new CategoryMarker(iterName); marker.setDrawAsLine(true); marker.setPaint(vm.getPaint()); plot.addDomainMarker(marker); LineAndShapeRenderer renderer = (LineAndShapeRenderer) plot.getRenderer(); renderer.setShapesVisible(true); renderer.setDrawOutlines(true); renderer.setUseFillPaint(true); renderer.setFillPaint(Color.WHITE); renderer.setSeriesPaint(0, Color.BLUE.darker()); try { ChartUtilities.saveChartAsJPEG(new File(Utils.getFullImageName(record.name + "_results")), chart, 300, 200); } catch (Exception e) { System.out.println("Problems..."); } }
From source file:org.squale.squaleweb.util.graph.AuditsSizeMaker.java
/** * Constructeur par dfaut */ public AuditsSizeMaker() { mDataSet = new DefaultCategoryDataset(); }
From source file:jgnash.ui.budget.BudgetSparkline.java
public static Icon getSparklineImage(final List<BigDecimal> amounts) { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); final boolean[] negate = new boolean[amounts.size()]; for (int i = 0; i < amounts.size(); i++) { dataset.addValue(amounts.get(i), CATEGORY, i); negate[i] = amounts.get(i).signum() == -1; }/* w w w . j ava 2 s.c o m*/ CategoryAxis xAxis = new CategoryAxis(); xAxis.setTickLabelsVisible(false); xAxis.setTickMarksVisible(false); xAxis.setAxisLineVisible(false); xAxis.setVisible(false); NumberAxis yAxis = new NumberAxis(); yAxis.setTickLabelsVisible(false); yAxis.setTickMarksVisible(false); yAxis.setAxisLineVisible(false); yAxis.setNegativeArrowVisible(false); yAxis.setPositiveArrowVisible(false); yAxis.setAutoRangeIncludesZero(true); yAxis.setAutoRange(true); yAxis.setVisible(false); BarRenderer renderer = new BarRenderer() { @Override public Paint getItemPaint(final int row, final int column) { return negate[column] ? Color.RED : Color.BLACK; } }; renderer.setShadowVisible(false); renderer.setBarPainter(new StandardBarPainter()); CategoryPlot plot = new CategoryPlot(dataset, xAxis, yAxis, renderer); plot.setInsets(INSETS); plot.setDomainGridlinesVisible(false); plot.setDomainCrosshairVisible(false); plot.setRangeGridlinesVisible(false); plot.setRangeCrosshairVisible(false); plot.setBackgroundPaint(CLEAR); JFreeChart chart = new JFreeChart(null, JFreeChart.DEFAULT_TITLE_FONT, plot, false); chart.setBorderVisible(false); chart.setBackgroundPaint(CLEAR); Icon icon = EMPTY_ICON; try { byte[] image = ENCODER .encode(chart.createBufferedImage(DEFAULT_WIDTH, DEFAULT_HEIGHT, BufferedImage.BITMASK, null)); icon = new ImageIcon(image); } catch (IOException ex) { Logger.getLogger(BudgetSparkline.class.getName()).log(Level.SEVERE, null, ex); } return icon; }