List of usage examples for org.jfree.chart.plot PlotOrientation VERTICAL
PlotOrientation VERTICAL
To view the source code for org.jfree.chart.plot PlotOrientation VERTICAL.
Click Source Link
From source file:loansystem.visual.panel.StartPage.java
private void graficoPrestamoXMes() { ArrayList<GraficoEntidad> graficos; graficos = gDao.obtenerPrestamosPorMes(); if (graficos.size() > 0) { DefaultCategoryDataset datos = new DefaultCategoryDataset(); for (GraficoEntidad result : graficos) { datos.addValue(result.getValor(), result.getSerie(), result.getValorEje()); }/*from www . ja v a2 s . c o m*/ JFreeChart grafica = ChartFactory.createBarChart("Registros Por Mes", "Mes", "Prstamos", datos, PlotOrientation.VERTICAL, true, true, false); ChartPanel panel = new ChartPanel(grafica); pnelPrestamosMes.add(panel); pnelPrestamosMes.revalidate(); pnelPrestamosMes.repaint(); } }
From source file:org.jgrasstools.gears.utils.chart.CategoryHistogram.java
public JFreeChart getChart() { if (chart == null) { createDataset();//from w ww.j ava 2 s .co m chart = ChartFactory.createBarChart(title, // chart title "Category", // domain axis label "Value", // range axis label dataset, // data PlotOrientation.VERTICAL, // orientation false, // include legend true, // tooltips? false // URLs? ); CategoryPlot plot = (CategoryPlot) chart.getPlot(); CategoryAxis rangeAxis = plot.getDomainAxis(); rangeAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_90); } return chart; }
From source file:org.jboss.weld.benchmark.charts.Chart.java
/** * Saving a chart to hard disk as png image * * @param path absolute path/*from ww w. j a v a 2 s . c om*/ * @return true if no errors occurred */ public Boolean saveImageTo(String path) { try { JFreeChart lineChartObject = ChartFactory.createBarChart(NAME, X_AXIS_NAME, Y_AXIS_NAME, lineChartDataset, PlotOrientation.VERTICAL, true, true, false); CategoryPlot plot = (CategoryPlot) lineChartObject.getPlot(); plot.setDomainAxis(new CategoryAxis() { private static final long serialVersionUID = 1L; @Override protected TextBlock createLabel(@SuppressWarnings("rawtypes") Comparable category, float width, RectangleEdge edge, Graphics2D g2) { TextBlock label = TextUtilities.createTextBlock(category.toString(), getTickLabelFont(category), getTickLabelPaint(category), ONE_PART_WIDTH - 30, 2, new G2TextMeasurer(g2)); label.setLineAlignment(HorizontalAlignment.LEFT); return label; } }); File lineChart = new File(path, NAME + ".png"); ChartUtilities.saveChartAsPNG(lineChart, lineChartObject, ONE_PART_WIDTH * lineChartDataset.getColumnCount(), GRAPH_HEIGHT); } catch (IOException e) { e.printStackTrace(); return false; } return true; }
From source file:umontreal.iro.lecuyer.charts.EmpiricalChart.java
protected void init(String title, String XLabel, String YLabel) { // create the chart... chart = ChartFactory.createXYLineChart(title, // chart title XLabel, // x axis label YLabel, // y axis label dataset.getSeriesCollection(), // data PlotOrientation.VERTICAL, true, // include legend true, // tool tips false // urls );//from ww w .j a va 2 s . com ((XYPlot) chart.getPlot()).setRenderer(dataset.getRenderer()); // Initialize axis variables XAxis = new Axis((NumberAxis) ((XYPlot) chart.getPlot()).getDomainAxis(), Axis.ORIENTATION_HORIZONTAL); YAxis = new Axis((NumberAxis) ((XYPlot) chart.getPlot()).getRangeAxis(), Axis.ORIENTATION_VERTICAL); fixZeroPoint(); }
From source file:org.tap4j.plugin.util.GraphHelper.java
public static JFreeChart createChart(StaplerRequest req, CategoryDataset dataset) { final JFreeChart chart = ChartFactory.createStackedAreaChart("TAP Tests", // chart title null, // unused "TAP Tests Count", // range axis label dataset, // data PlotOrientation.VERTICAL, // orientation true, // include legend true, // tooltips false // urls );/*from w w w.ja va2s .c o m*/ // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... final LegendTitle legend = chart.getLegend(); legend.setPosition(RectangleEdge.RIGHT); chart.setBackgroundPaint(Color.white); final CategoryPlot plot = chart.getCategoryPlot(); plot.setBackgroundPaint(Color.WHITE); plot.setOutlinePaint(null); plot.setForegroundAlpha(0.8f); plot.setDomainGridlinesVisible(true); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinesVisible(true); plot.setRangeGridlinePaint(Color.black); CategoryAxis domainAxis = new ShiftedCategoryAxis(null); plot.setDomainAxis(domainAxis); domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_90); domainAxis.setLowerMargin(0.0); domainAxis.setUpperMargin(0.0); domainAxis.setCategoryMargin(0.0); final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); StackedAreaRenderer ar = new StackedAreaRenderer2() { private static final long serialVersionUID = 331915263367089058L; @Override public String generateURL(CategoryDataset dataset, int row, int column) { NumberOnlyBuildLabel label = (NumberOnlyBuildLabel) dataset.getColumnKey(column); return label.build.getNumber() + "/" + AbstractTapProjectAction.URL_NAME + "/"; } @Override public String generateToolTip(CategoryDataset dataset, int row, int column) { NumberOnlyBuildLabel label = (NumberOnlyBuildLabel) dataset.getColumnKey(column); TapBuildAction build = label.build.getAction(TapBuildAction.class); TapResult report = build.getResult(); report.tally(); switch (row) { case 0: return String.valueOf(report.getFailed()) + " Failure(s)"; case 1: return String.valueOf(report.getPassed()) + " Pass"; case 2: return String.valueOf(report.getSkipped()) + " Skip(s)"; default: return ""; } } }; plot.setRenderer(ar); ar.setSeriesPaint(0, ColorPalette.RED); // Failures ar.setSeriesPaint(1, ColorPalette.BLUE); // Pass ar.setSeriesPaint(2, ColorPalette.YELLOW); // Skips // crop extra space around the graph plot.setInsets(new RectangleInsets(0, 0, 0, 5.0)); return chart; }
From source file:org.dkpro.tc.ml.report.util.ScatterplotRenderer.java
@Override public void write(OutputStream aStream) throws IOException { JFreeChart chart = ChartFactory.createXYLineChart("Scatterplot", "Gold", "Prediction", aDataset, PlotOrientation.VERTICAL, false, false, false); XYDotRenderer renderer = new XYDotRenderer(); renderer.setDotHeight(2);// w w w . jav a 2s . com renderer.setDotWidth(2); double padding = (max - min) / 10; chart.getXYPlot().setRenderer(renderer); chart.getXYPlot().getRangeAxis().setRange(min - padding, max + padding); chart.getXYPlot().getDomainAxis().setRange(min - padding, max + padding); ChartUtil.writeChartAsPDF(aStream, chart, 400, 400); }
From source file:org.uncommons.maths.demo.GraphPanel.java
public void generateGraph(String title, Map<Double, Double> observedValues, Map<Double, Double> expectedValues, double expectedMean, double expectedStandardDeviation, boolean discrete) { XYSeriesCollection dataSet = new XYSeriesCollection(); XYSeries observedSeries = new XYSeries("Observed"); dataSet.addSeries(observedSeries);//from ww w . j av a 2 s .c o m XYSeries expectedSeries = new XYSeries("Expected"); dataSet.addSeries(expectedSeries); for (Map.Entry<Double, Double> entry : observedValues.entrySet()) { observedSeries.add(entry.getKey(), entry.getValue()); } for (Map.Entry<Double, Double> entry : expectedValues.entrySet()) { expectedSeries.add(entry.getKey(), entry.getValue()); } JFreeChart chart = ChartFactory.createXYLineChart(title, "Value", "Probability", dataSet, PlotOrientation.VERTICAL, true, false, false); XYPlot plot = (XYPlot) chart.getPlot(); if (discrete) { // Render markers at each data point (these discrete points are the // distibution, not the lines between them). plot.setRenderer(new XYLineAndShapeRenderer()); } else { // Render smooth lines between points for a continuous distribution. XYSplineRenderer renderer = new XYSplineRenderer(); renderer.setBaseShapesVisible(false); plot.setRenderer(renderer); } chartPanel.setChart(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);/*w w w. j a 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.jfree.chart.demo.NormalDistributionDemo2.java
public static JFreeChart createChart(XYDataset xydataset) { JFreeChart jfreechart = ChartFactory.createXYLineChart("Normal Distribution Demo 2", "X", "Y", xydataset, PlotOrientation.VERTICAL, true, true, false); XYPlot xyplot = (XYPlot) jfreechart.getPlot(); xyplot.setDomainZeroBaselineVisible(true); xyplot.setRangeZeroBaselineVisible(true); xyplot.setDomainPannable(true);/*from w ww . j av a 2s . c o m*/ xyplot.setRangePannable(true); ValueAxis valueaxis = xyplot.getDomainAxis(); valueaxis.setLowerMargin(0.0D); valueaxis.setUpperMargin(0.0D); XYLineAndShapeRenderer xylineandshaperenderer = (XYLineAndShapeRenderer) xyplot.getRenderer(); xylineandshaperenderer.setDrawSeriesLineAsPath(true); xylineandshaperenderer.setSeriesStroke(0, new BasicStroke(1.5F)); xylineandshaperenderer.setSeriesStroke(1, new BasicStroke(2.0F, 1, 1, 1.0F, new float[] { 6F, 4F }, 0.0F)); xylineandshaperenderer.setSeriesStroke(2, new BasicStroke(2.0F, 1, 1, 1.0F, new float[] { 6F, 4F, 3F, 3F }, 0.0F)); xylineandshaperenderer.setSeriesStroke(3, new BasicStroke(2.0F, 1, 1, 1.0F, new float[] { 4F, 4F }, 0.0F)); XYPointerAnnotation xypointerannotation = new XYPointerAnnotation(" = -2.0, \262 = 0.5", -2D, 0.56399999999999995D, 3.9269908169872414D); xypointerannotation.setLabelOffset(4D); xypointerannotation.setTextAnchor(TextAnchor.BOTTOM_RIGHT); xypointerannotation.setBackgroundPaint(Color.yellow); xyplot.addAnnotation(xypointerannotation); XYPointerAnnotation xypointerannotation1 = new XYPointerAnnotation(" = 0.0, \262 = 0.2", 0.22500000000000001D, 0.80000000000000004D, 0.0D); xypointerannotation1.setLabelOffset(4D); xypointerannotation1.setTextAnchor(TextAnchor.CENTER_LEFT); xypointerannotation1.setBackgroundPaint(new Color(0, 0, 255, 63)); xyplot.addAnnotation(xypointerannotation1); XYPointerAnnotation xypointerannotation2 = new XYPointerAnnotation(" = 0.0, \262 = 1.0", 0.75D, 0.29999999999999999D, 5.497787143782138D); xypointerannotation2.setLabelOffset(4D); xypointerannotation2.setTextAnchor(TextAnchor.HALF_ASCENT_LEFT); xypointerannotation2.setBackgroundPaint(new Color(255, 0, 0, 63)); xyplot.addAnnotation(xypointerannotation2); XYPointerAnnotation xypointerannotation3 = new XYPointerAnnotation(" = 0.0, \262 = 5.0", 3D, 0.074999999999999997D, 4.7123889803846897D); xypointerannotation3.setLabelOffset(4D); xypointerannotation3.setTextAnchor(TextAnchor.BOTTOM_CENTER); xypointerannotation3.setBackgroundPaint(new Color(0, 255, 0, 63)); xyplot.addAnnotation(xypointerannotation3); return jfreechart; }
From source file:org.jfree.chart.demo.ScatterPlotDemo.java
/** * A demonstration application showing a scatter plot. * //from www . ja v a 2 s.co m * @param title * the frame title. */ public ScatterPlotDemo(final String title) { super(title); final XYDataset data = new SampleXYDataset2(); final JFreeChart chart = ChartFactory.createScatterPlot("Scatter Plot Demo", "X", "Y", data, PlotOrientation.VERTICAL, true, true, false); final Legend legend = chart.getLegend(); if (legend instanceof StandardLegend) { final StandardLegend sl = (StandardLegend) legend; sl.setDisplaySeriesShapes(true); } XYPlot plot = (XYPlot) chart.getPlot(); plot.setNoDataMessage("NO DATA"); final NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis(); domainAxis.setAutoRangeIncludesZero(false); final ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new java.awt.Dimension(500, 270)); chartPanel.setVerticalAxisTrace(true); chartPanel.setHorizontalAxisTrace(true); chartPanel.setVerticalZoom(true); chartPanel.setHorizontalZoom(true); setContentPane(chartPanel); }