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:com.rapidminer.gui.plotter.charts.BarChart2DPlotter.java
public JFreeChart createChart(CategoryDataset categoryDataSet, String groupByName, String valueName, boolean createLegend) { JFreeChart chart = ChartFactory.createBarChart(null, // chart title groupByName, // domain axis label valueName, // range axis label categoryDataSet, // data PlotOrientation.VERTICAL, // orientation ((createLegend) && (groupByName != null)), // include legend if group by column is set true, // tooltips false // URLs );//from ww w.j a v a 2 s .c o m // get a reference to the plot for further customisation... CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.setBackgroundPaint(new Color(230, 230, 230)); plot.setDomainGridlinePaint(Color.white); plot.setDomainGridlinesVisible(true); plot.setRangeGridlinePaint(Color.white); // set up paints for series if (groupByName == null) { BarRenderer renderer = (BarRenderer) plot.getRenderer(); renderer.setSeriesPaint(0, SwingTools.LIGHT_BLUE); renderer.setSeriesPaint(1, SwingTools.LIGHT_YELLOW); } // domain axis labels CategoryAxis domainAxis = plot.getDomainAxis(); if (groupByName == null) { domainAxis.setTickLabelsVisible(true); domainAxis.setCategoryLabelPositions( CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 6.0)); } else { domainAxis.setTickLabelsVisible(false); } return chart; }
From source file:com.rapidminer.gui.plotter.charts.BarChart3DPlotter.java
public JFreeChart createChart(CategoryDataset categoryDataSet, String groupByName, String valueName, boolean createLegend) { JFreeChart chart = ChartFactory.createBarChart3D(null, // chart title groupByName, // domain axis label valueName, // range axis label categoryDataSet, // data PlotOrientation.VERTICAL, // orientation ((createLegend) && (groupByName != null)), // include legend if group by column is set true, // tooltips false // URLs );// w w w .jav a 2 s.c o m // get a reference to the plot for further customisation... CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.setBackgroundPaint(new Color(230, 230, 230)); plot.setDomainGridlinePaint(Color.white); plot.setDomainGridlinesVisible(true); plot.setRangeGridlinePaint(Color.white); // set up paints for series if (groupByName == null) { BarRenderer renderer = (BarRenderer) plot.getRenderer(); renderer.setSeriesPaint(0, SwingTools.LIGHT_BLUE); renderer.setSeriesPaint(1, SwingTools.LIGHT_YELLOW); } // domain axis labels CategoryAxis domainAxis = plot.getDomainAxis(); if (groupByName == null) { domainAxis.setTickLabelsVisible(true); domainAxis.setCategoryLabelPositions( CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 6.0)); } else { domainAxis.setTickLabelsVisible(false); } return chart; }
From source file:org.matsim.contrib.dvrp.util.chart.RouteCharts.java
public static JFreeChart chartRoutes(Collection<? extends Vehicle> vehicles) { CoordDataset lData = new CoordDataset(); int i = 0;/* w ww . ja v a 2 s . c o m*/ for (Vehicle v : vehicles) { Schedule schedule = v.getSchedule(); lData.addSeries(Integer.toString(i++), ScheduleCoordSources.createCoordSource(schedule)); } JFreeChart chart = ChartFactory.createXYLineChart("Routes", "X", "Y", lData, PlotOrientation.VERTICAL, true, true, false); XYPlot plot = (XYPlot) chart.getPlot(); plot.setRangeGridlinesVisible(false); plot.setDomainGridlinesVisible(false); plot.setBackgroundPaint(Color.white); NumberAxis yAxis = (NumberAxis) plot.getRangeAxis(); yAxis.setAutoRangeIncludesZero(false); XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer(); renderer.setSeriesShapesVisible(0, true); renderer.setSeriesLinesVisible(0, false); renderer.setSeriesItemLabelsVisible(0, true); renderer.setBaseItemLabelGenerator(new XYItemLabelGenerator() { public String generateLabel(XYDataset dataset, int series, int item) { return ((CoordDataset) dataset).getText(series, item); } }); for (int j = 1; j <= vehicles.size(); j++) { renderer.setSeriesShapesVisible(j, true); renderer.setSeriesLinesVisible(j, true); renderer.setSeriesItemLabelsVisible(j, true); } return chart; }
From source file:no.ntnu.mmfplanner.ui.graph.SaNpvChart.java
/** * Creates the chart//ww w . j av a2 s . c om */ private void createChart() { JFreeChart chart = ChartFactory.createXYLineChart(null, // chart title "Period", // x axis label "Discounted Cash", // y axis label null, // data PlotOrientation.VERTICAL, true, // include legend true, // tooltips false // urls ); XYPlot plot = (XYPlot) chart.getPlot(); plot.getDomainAxis().setLowerMargin(0.0); plot.getDomainAxis().setUpperMargin(0.0); plot.setRangeAxisLocation(1, AxisLocation.BOTTOM_OR_LEFT); // change the auto tick unit selection to integer units only... NumberAxis rangeAxis = (NumberAxis) plot.getDomainAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); setChart(chart); setMouseZoomable(false); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); renderer.setLegendLine(new Rectangle2D.Double(0.0, 0.0, 6.0, 0.0)); renderer.setUseFillPaint(true); // the x=0 line renderer.setSeriesPaint(0, Color.GRAY); renderer.setSeriesShapesVisible(0, false); renderer.setSeriesLinesVisible(0, true); renderer.setSeriesVisibleInLegend(0, new Boolean(false)); plot.setRenderer(renderer); }
From source file:org.radargun.reporting.BarPlotGenerator.java
/** * @param operation Name of the plotted operation * @param ranges ranges[0] = min, ranges[ranges.length - 1] = max * @param counts counts[i] is number of entries with value >= ranges[i - 1] and < ranges[i] * @param reportDir//from w w w . ja v a 2 s .c o m * @param filename * @throws IOException */ public static void generate(String operation, long[] ranges, long[] counts, String reportDir, String filename) throws IOException { XYSeries series = new XYSeries(operation + " response times"); long totalCount = 0; for (long count : counts) { totalCount += count; } double left = Math.log10(ranges[0]); double right = Math.log10(ranges[ranges.length - 1]); for (int i = 0; i < counts.length; i++) { series.add(Math.log10(ranges[i]), (double) counts[i] / totalCount); } series.add(right, 0d); XYDataset dataset = new XYSeriesCollection(series); JFreeChart chart = ChartFactory.createXYStepAreaChart(operation + " response time histogram", "Response time", "Percentage", dataset, PlotOrientation.VERTICAL, false, false, false); XYPlot plot = (XYPlot) chart.getPlot(); NumberAxis d = (NumberAxis) plot.getDomainAxis(); d.setRange(left, right); d.setStandardTickUnits(new HistoTickUnitSource()); plot.setDomainAxis(d); FileOutputStream output = new FileOutputStream(new File(reportDir + File.separator + filename)); ChartUtilities.writeChartAsPNG(output, chart, 1024, 768); output.close(); }
From source file:net.sourceforge.processdash.ui.web.reports.AreaChart.java
/** Create a line chart. */ public JFreeChart createChart() { JFreeChart chart;//from w w w. j a v a 2 s .c om CategoryDataset catData = data.catDataSource(); Object stacked = parameters.get("stacked"); if (stacked != null) { chart = ChartFactory.createStackedAreaChart(null, null, null, catData, PlotOrientation.VERTICAL, true, true, false); if ("pct".equals(stacked)) { ((StackedAreaRenderer) chart.getCategoryPlot().getRenderer()).setRenderAsPercentages(true); DecimalFormat fmt = new DecimalFormat(); fmt.setMultiplier(100); ((NumberAxis) chart.getCategoryPlot().getRangeAxis()).setNumberFormatOverride(fmt); if (parameters.get("units") == null) parameters.put("units", "%"); } } else { chart = ChartFactory.createAreaChart(null, null, null, catData, PlotOrientation.VERTICAL, true, true, false); } setupCategoryChart(chart); Object colorScheme = parameters.get("colorScheme"); if ("consistent".equals(colorScheme)) configureConsistentColors(chart.getCategoryPlot(), catData); else if (parameters.containsKey("c1")) configureIndividualColors(chart.getCategoryPlot(), catData); return chart; }
From source file:net.relet.freimap.LinkInfo.java
public void setLinkProfile(LinkedList<LinkData> lp) { XYSeries data = new XYSeries("etx"); XYSeries avail = new XYSeries("avail"); XYSeriesCollection datac = new XYSeriesCollection(data); datac.addSeries(avail);//from w w w . j a v a2s.c o m linkChart = ChartFactory.createXYLineChart("average link etx\r\naverage link availability", "time", "etx", datac, PlotOrientation.VERTICAL, false, false, false); sexupLayout(linkChart); long first = lp.getFirst().time, last = lp.getLast().time, lastClock = first, count = 0, //number of samplis in aggregation timespan maxCount = 0; //max idem long aggregate = (last - first) / CHART_WIDTH; //calculate aggregation timespan: divide available timespan in CHART_WIDTH equal chunks double sum = 0; /* ok, this ain't effective, we do it just to pre-calculate maxCount */ ListIterator<LinkData> li = lp.listIterator(); while (li.hasNext()) { LinkData ld = li.next(); count++; if (ld.time - lastClock > aggregate) { if (maxCount < count) maxCount = count; lastClock = ld.time; count = 0; } } //reset for second iteration count = 0; lastClock = first; //iterate again li = lp.listIterator(); while (li.hasNext()) { LinkData ld = li.next(); sum += ld.quality; count++; if (aggregate == 0) aggregate = 1000;//dirty hack if (ld.time - lastClock > aggregate) { for (long i = lastClock; i < ld.time - aggregate; i += aggregate) { data.add(i * 1000, (i == lastClock) ? sum / count : Double.NaN); avail.add(i * 1000, (i == lastClock) ? ((double) count / maxCount) : 0); } count = 0; sum = 0; lastClock = ld.time; } } status = STATUS_AVAILABLE; }
From source file:org.jfree.chart.demo.BarChart3DDemo4.java
private static JFreeChart createChart(CategoryDataset categorydataset) { JFreeChart jfreechart = ChartFactory.createBarChart3D("Student Grades", "Students", "Grade", categorydataset, PlotOrientation.VERTICAL, false, true, false); CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot(); CustomBarRenderer3D custombarrenderer3d = new CustomBarRenderer3D(); custombarrenderer3d.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator()); custombarrenderer3d.setBaseItemLabelsVisible(true); custombarrenderer3d.setItemLabelAnchorOffset(10D); custombarrenderer3d.setBasePositiveItemLabelPosition( new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BASELINE_LEFT)); categoryplot.setRenderer(custombarrenderer3d); ValueMarker valuemarker = new ValueMarker(0.69999999999999996D, new Color(200, 200, 255), new BasicStroke(1.0F), new Color(200, 200, 255), new BasicStroke(1.0F), 1.0F); categoryplot.addRangeMarker(valuemarker, Layer.BACKGROUND); custombarrenderer3d.setBaseItemLabelsVisible(true); custombarrenderer3d.setMaximumBarWidth(0.050000000000000003D); CategoryTextAnnotation categorytextannotation = new CategoryTextAnnotation("Minimum grade to pass", "Robert", 0.70999999999999996D); categorytextannotation.setCategoryAnchor(CategoryAnchor.START); categorytextannotation.setFont(new Font("SansSerif", 0, 12)); categorytextannotation.setTextAnchor(TextAnchor.BOTTOM_LEFT); categoryplot.addAnnotation(categorytextannotation); NumberAxis numberaxis = (NumberAxis) categoryplot.getRangeAxis(); numberaxis.setNumberFormatOverride(NumberFormat.getPercentInstance()); numberaxis.setUpperMargin(0.10000000000000001D); return jfreechart; }
From source file:edu.emory.library.tast.database.graphs.GraphTypeBar.java
public JFreeChart createChart(Object[] data) { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); JFreeChart chart = ChartFactory.createBarChart(null, getSelectedIndependentVariable().getLabel(), TastResource.getText("components_charts_barvalue"), dataset, PlotOrientation.VERTICAL, true, true, false);/*from w w w . java2 s . c om*/ CategoryPlot plot = chart.getCategoryPlot(); plot.getDomainAxis().setMaximumCategoryLabelLines(5); plot.getDomainAxis().setCategoryLabelPositions(CategoryLabelPositions.DOWN_90); chart.setBackgroundPaint(Color.white); Format formatter = getSelectedIndependentVariable().getFormat(); List allDataSeries = getDataSeries(); for (int j = 0; j < allDataSeries.size(); j++) { DataSeries dataSearies = (DataSeries) allDataSeries.get(j); String dataSeriesLabel = dataSearies.formatForDisplay(); for (int i = 0; i < data.length; i++) { Object[] row = (Object[]) data[i]; String cat = formatter == null ? row[0].toString() : formatter.format(row[0]); dataset.addValue((Number) row[j + 1], dataSeriesLabel, cat); } } LegendItemCollection legendItems = chart.getPlot().getLegendItems(); for (int i = 0; i < legendItems.getItemCount(); i++) { LegendItem legendItem = legendItems.get(i); DataSeries dataSearies = (DataSeries) allDataSeries.get(i); if (legendItem.getFillPaint() instanceof Color) { dataSearies.setColor(((Color) legendItem.getFillPaint())); } } return chart; }
From source file:org.jboss.seam.cron.examples.swinggrapher.SwingGrapherForm.java
/** * Initialise the chart visuals.//from w w w. j a v a2 s . com */ @PostConstruct public void initChart() { log.info("Initializing"); final JFreeChart chart = ChartFactory.createLineChart3D("Free Memory", "Time", "Bytes", catDataSet, PlotOrientation.VERTICAL, true, true, true); final ChartPanel chartPanel = new ChartPanel(chart); setContentPane(chartPanel); }