List of usage examples for org.jfree.chart.axis CategoryAxis setCategoryLabelPositions
public void setCategoryLabelPositions(CategoryLabelPositions positions)
From source file:org.matsim.counts.algorithms.graphs.BoxPlotErrorGraph.java
@SuppressWarnings("unchecked") @Override/*from w w w. j a v a2 s . c o m*/ public JFreeChart createChart(final int nbr) { DefaultBoxAndWhiskerCategoryDataset dataset0 = new DefaultBoxAndWhiskerCategoryDataset(); DefaultBoxAndWhiskerCategoryDataset dataset1 = new DefaultBoxAndWhiskerCategoryDataset(); final ArrayList<Double>[] listRel = new ArrayList[24]; final ArrayList<Double>[] listAbs = new ArrayList[24]; // init for (int i = 0; i < 24; i++) { listRel[i] = new ArrayList<Double>(); listAbs[i] = new ArrayList<Double>(); } // add the values of all counting stations to each hour for (CountSimComparison cc : this.ccl_) { int hour = cc.getHour() - 1; listRel[hour].add(cc.calculateRelativeError()); listAbs[hour].add(cc.getSimulationValue() - cc.getCountValue()); } // add the collected values to the graph / dataset for (int i = 0; i < 24; i++) { dataset0.add(listRel[i], "Rel Error", Integer.toString(i + 1)); dataset1.add(listAbs[i], "Abs Error", Integer.toString(i + 1)); } String title = "Iteration: " + this.iteration_; final CombinedDomainCategoryPlot plot = new CombinedDomainCategoryPlot(); final CategoryAxis xAxis = new CategoryAxis("Hour"); final NumberAxis yAxis0 = new NumberAxis("Signed Rel. Error [%]"); final NumberAxis yAxis1 = new NumberAxis("Signed Abs. Error [veh]"); yAxis0.setAutoRangeIncludesZero(false); yAxis1.setAutoRangeIncludesZero(false); final BoxAndWhiskerRenderer renderer = new BoxAndWhiskerRenderer(); renderer.setFillBox(false); renderer.setSeriesPaint(0, Color.blue); renderer.setSeriesToolTipGenerator(0, new BoxAndWhiskerToolTipGenerator()); CategoryPlot subplot0 = new CategoryPlot(dataset0, xAxis, yAxis0, renderer); CategoryPlot subplot1 = new CategoryPlot(dataset1, xAxis, yAxis1, renderer); plot.add(subplot0); plot.add(subplot1); final CategoryAxis axis1 = new CategoryAxis("hour"); axis1.setTickLabelFont(new Font("SansSerif", Font.PLAIN, 7)); axis1.setCategoryLabelPositions(CategoryLabelPositions.UP_45); plot.setDomainAxis(axis1); this.chart_ = new JFreeChart(title, new Font("SansSerif", Font.BOLD, 14), plot, false); return this.chart_; }
From source file:org.matsim.counts.algorithms.graphs.BoxPlotNormalizedErrorGraph.java
@SuppressWarnings("unchecked") @Override/*ww w .jav a2s . c o m*/ public JFreeChart createChart(final int nbr) { DefaultBoxAndWhiskerCategoryDataset dataset0 = new DefaultBoxAndWhiskerCategoryDataset(); DefaultBoxAndWhiskerCategoryDataset dataset1 = new DefaultBoxAndWhiskerCategoryDataset(); final ArrayList<Double>[] listRel = new ArrayList[24]; final ArrayList<Double>[] listAbs = new ArrayList[24]; // init for (int i = 0; i < 24; i++) { listRel[i] = new ArrayList<Double>(); listAbs[i] = new ArrayList<Double>(); } // add the values of all counting stations to each hour for (CountSimComparison cc : this.ccl_) { int hour = cc.getHour() - 1; listRel[hour].add(cc.calculateNormalizedRelativeError() * 100); listAbs[hour].add(cc.getSimulationValue() - cc.getCountValue()); } // add the collected values to the graph / dataset for (int i = 0; i < 24; i++) { dataset0.add(listRel[i], "Rel Norm Error", Integer.toString(i + 1)); dataset1.add(listAbs[i], "Abs Error", Integer.toString(i + 1)); } String title = "Iteration: " + this.iteration_; final CombinedDomainCategoryPlot plot = new CombinedDomainCategoryPlot(); final CategoryAxis xAxis = new CategoryAxis("Hour"); final NumberAxis yAxis0 = new NumberAxis("Norm. Rel. Error [%]"); final NumberAxis yAxis1 = new NumberAxis("Signed Abs. Error [veh]"); yAxis0.setAutoRangeIncludesZero(false); yAxis1.setAutoRangeIncludesZero(false); final BoxAndWhiskerRenderer renderer = new BoxAndWhiskerRenderer(); renderer.setFillBox(false); renderer.setSeriesPaint(0, Color.blue); renderer.setSeriesToolTipGenerator(0, new BoxAndWhiskerToolTipGenerator()); CategoryPlot subplot0 = new CategoryPlot(dataset0, xAxis, yAxis0, renderer); CategoryPlot subplot1 = new CategoryPlot(dataset1, xAxis, yAxis1, renderer); plot.add(subplot0); plot.add(subplot1); final CategoryAxis axis1 = new CategoryAxis("hour"); axis1.setTickLabelFont(new Font("SansSerif", Font.PLAIN, 7)); axis1.setCategoryLabelPositions(CategoryLabelPositions.UP_45); plot.setDomainAxis(axis1); this.chart_ = new JFreeChart(title, new Font("SansSerif", Font.BOLD, 14), plot, false); return this.chart_; }
From source file:Client.Gui.TeamBarChart.java
/** * Creates a sample chart./* w w w . j a v a 2 s. co m*/ * * @param dataset the dataset. * * @return The chart. */ private JFreeChart createChart(final CategoryDataset dataset) { // create the chart... final JFreeChart chart = ChartFactory.createBarChart("Distribution of Trainging", // chart title "", // domain axis label "", // range axis label dataset, // data PlotOrientation.VERTICAL, // orientation true, // include legend true, // tooltips? false // URLs? ); // set the background color for the chart... chart.setBackgroundPaint(Color.white); // get a reference to the plot for further customisation... final CategoryPlot plot = chart.getCategoryPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); // set the range axis to display integers only... final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); // disable bar outlines... final BarRenderer renderer = (BarRenderer) plot.getRenderer(); renderer.setDrawBarOutline(false); // set up gradient paints for series... final GradientPaint gp0 = new GradientPaint(0.0f, 0.0f, Color.blue, 0.0f, 0.0f, Color.lightGray); final GradientPaint gp1 = new GradientPaint(0.0f, 0.0f, Color.green, 0.0f, 0.0f, Color.lightGray); final GradientPaint gp2 = new GradientPaint(0.0f, 0.0f, Color.red, 0.0f, 0.0f, Color.lightGray); renderer.setSeriesPaint(0, gp0); renderer.setSeriesPaint(1, gp1); renderer.setSeriesPaint(2, gp2); final CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 6.0)); return chart; }
From source file:net.nosleep.superanalyzer.analysis.views.TimeView.java
private void createChart() { // create the chart... _chart = ChartFactory.createLineChart(Misc.getString("LISTENING_TIMES"), // chart // title Misc.getString("HOUR_OF_DAY"), // domain axis label Misc.getString("SONG_COUNT"), // range axis label _dataset, // data PlotOrientation.VERTICAL, // orientation false, // include legend true, // tooltips false // urls );/*from w w w .ja v a 2 s . c o m*/ CategoryPlot plot = (CategoryPlot) _chart.getPlot(); plot.setRangePannable(true); plot.setRangeZeroBaselineVisible(false); CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setCategoryLabelPositions(CategoryLabelPositions.DOWN_45); _chart.addSubtitle(HomePanel.createSubtitle(Misc.getString("LISTENING_TIMES_TOOLTIP"))); ChartUtilities.applyCurrentTheme(_chart); // format the renderer after applying the theme LineAndShapeRenderer renderer = (LineAndShapeRenderer) plot.getRenderer(); renderer.setBaseShapesVisible(true); renderer.setDrawOutlines(true); renderer.setUseFillPaint(true); renderer.setBaseFillPaint(Color.white); renderer.setSeriesStroke(0, new BasicStroke(3.0f)); renderer.setSeriesOutlineStroke(0, new BasicStroke(2.0f)); renderer.setSeriesShape(0, new Ellipse2D.Double(-4.0, -4.0, 8.0, 8.0)); // get rid of the little line above/next to the axis // plot.setRangeZeroBaselinePaint(Color.white); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); rangeAxis.setAutoRangeIncludesZero(true); Misc.formatChart(plot); renderer.setSeriesPaint(0, Theme.getColorSet()[1]); }
From source file:edu.indiana.htrc.visual.HTRCBarChartDrawer.java
@Override public File draw() { System.out.println("draw bar!!!!!!!!!!!!!"); DefaultCategoryDataset bar_dataset = new DefaultCategoryDataset(); /*dataset.setValue(6, "Profit", "Jane"); dataset.setValue(7, "Profit", "Tom"); dataset.setValue(8, "Profit", "Jill"); dataset.setValue(5, "Profit", "John"); dataset.setValue(12, "Profit", "Fred");*/ Set<String> key_set = input_map.keySet(); Iterator<String> iter = key_set.iterator(); while (iter.hasNext()) { String key = iter.next(); int value = input_map.get(key); bar_dataset.setValue(value, dataset_label, key); }//from w ww . j av a 2 s .c o m JFreeChart chart = null; if (is3D) { chart = ChartFactory.createBarChart3D(chart_name, x_axis_label, y_axis_label, bar_dataset, PlotOrientation.VERTICAL, true, true, false); } else { chart = ChartFactory.createBarChart(chart_name, x_axis_label, y_axis_label, bar_dataset, PlotOrientation.VERTICAL, true, true, false); } CategoryPlot p = chart.getCategoryPlot(); /* NumberAxis rangeAxis = (NumberAxis) p.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());*/ BarRenderer renderer = (BarRenderer) p.getRenderer(); DecimalFormat decimalformat1 = new DecimalFormat("##"); StandardCategoryItemLabelGenerator label_generator = new StandardCategoryItemLabelGenerator("{2}", decimalformat1); renderer.setItemLabelGenerator(label_generator); final ItemLabelPosition pos = new ItemLabelPosition(ItemLabelAnchor.OUTSIDE1, TextAnchor.CENTER_RIGHT, TextAnchor.CENTER_RIGHT, 0/* -Math.PI / 2.0*/ ); renderer.setPositiveItemLabelPosition(pos); final CategoryAxis domainAxis = p.getDomainAxis(); domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45); renderer.setMaximumBarWidth(.15); renderer.setItemLabelsVisible(true); chart.getCategoryPlot().setRenderer(renderer); File img = new File("../webapps/HTRC-UI-AuditAnalyzer/images/" + System.currentTimeMillis() + ".jpg"); try { ChartUtilities.saveChartAsJPEG(img, chart, 1400, 600); } catch (IOException e) { System.err.println("Problem occurred creating chart."); } return img; }
From source file:peakmlviewer.dialog.peakinformation.Graph.java
public Graph(Composite parent) { super(parent, SWT.EMBEDDED); setLayout(new FillLayout()); // create the chart linechart = ChartFactory.createLineChart(null, "", "Abundance", dataset_intensity, PlotOrientation.VERTICAL, false, // legend false, // tooltips false // urls );/*from w w w .jav a2 s. c o m*/ CategoryPlot plot = (CategoryPlot) linechart.getPlot(); // make the labels for the xaxis 45 degrees CategoryAxis xaxis = (CategoryAxis) plot.getDomainAxis(); xaxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45); // add the mass accuracy yaxis NumberAxis yaxis_massacc = new NumberAxis("Mass accuracy (ppm)"); plot.setRangeAxis(1, yaxis_massacc); plot.setRangeAxisLocation(1, AxisLocation.BOTTOM_OR_RIGHT); // create the mass accuracy dataset dataset_ppm = new DefaultCategoryDataset(); plot.setDataset(1, dataset_ppm); plot.mapDatasetToRangeAxis(1, 1); // create the renderer for the mass accuracy dataset LineAndShapeRenderer renderer_ppm = new LineAndShapeRenderer(); renderer_ppm.setBaseShapesFilled(true); renderer_ppm.setBaseShapesVisible(true); renderer_ppm.setBaseStroke( new BasicStroke(1, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_ROUND, 1, new float[] { 5, 5 }, 0)); plot.setRenderer(1, renderer_ppm); // setup the renderer for the intensity dataset LineAndShapeRenderer renderer = (LineAndShapeRenderer) plot.getRenderer(); renderer.setBaseShapesFilled(true); renderer.setBaseShapesVisible(true); // general properties linechart.setBackgroundPaint(Color.WHITE); linechart.setBorderVisible(false); linechart.setAntiAlias(true); plot.setBackgroundPaint(Color.WHITE); plot.setDomainGridlinesVisible(true); plot.setRangeGridlinesVisible(true); // add the components // -------------------------------------------------------------------------------- // This uses the SWT-trick for embedding awt-controls in an SWT-Composit. try { System.setProperty("sun.awt.noerasebackground", "true"); } catch (NoSuchMethodError error) { ; } java.awt.Frame frame = org.eclipse.swt.awt.SWT_AWT.new_Frame(this); // create a new ChartPanel, without the popup-menu (5x false) frame.add(new ChartPanel(linechart, false, false, false, false, false)); // -------------------------------------------------------------------------------- }
From source file:chart.DualAxis.java
/** * Creates a new demo instance./* w ww .j ava2s . c om*/ * * @param title the frame title. */ public DualAxis(final String title, double[] xData, double[] YDataAnalitic, double[] YDataNumerical) { super(title); final CategoryDataset dataset1 = createDataset1(xData, YDataAnalitic); // create the chart... final JFreeChart chart = ChartFactory.createLineChart("", // chart title "x", // domain axis label "y", // range axis label dataset1, // data PlotOrientation.VERTICAL, true, // include legend true, // tooltips? false // URL generator? Not required... ); // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... chart.setBackgroundPaint(Color.white); // chart.getLegend().setAnchor(Legend.SOUTH); // get a reference to the plot for further customisation... final CategoryPlot plot = chart.getCategoryPlot(); plot.setBackgroundPaint(new Color(0xEE, 0xEE, 0xFF)); plot.setDomainAxisLocation(AxisLocation.BOTTOM_OR_RIGHT); final CategoryDataset dataset2 = createDataset2(xData, YDataNumerical); plot.setDataset(1, dataset2); plot.mapDatasetToRangeAxis(1, 1); final CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setCategoryLabelPositions(CategoryLabelPositions.DOWN_45); //final ValueAxis axis2 = new NumberAxis(""); final ValueAxis axis2 = new NumberAxis(" "); plot.setRangeAxis(1, axis2); final LineAndShapeRenderer renderer2 = new LineAndShapeRenderer(); renderer2.setToolTipGenerator(new StandardCategoryToolTipGenerator()); plot.setRenderer(1, renderer2); plot.setDatasetRenderingOrder(DatasetRenderingOrder.REVERSE); // OPTIONAL CUSTOMISATION COMPLETED. // add the chart to a panel... final ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new java.awt.Dimension(500, 270)); setContentPane(chartPanel); // panel.removeAll(); // panel.add(chartPanel); // panel.validate(); }
From source file:com.thalesgroup.hudson.plugins.cppcheck.graph.CppcheckGraph.java
/** * Creates a Cppcheck trend graph// w w w . j a v a 2 s . com * * @return the JFreeChart graph object */ protected JFreeChart createGraph() { final JFreeChart chart = ChartFactory.createLineChart(null, // chart title null, // unused yLabel, // range axis label categoryDataset, // data PlotOrientation.VERTICAL, // orientation true, // include legend true, // tooltips false // urls ); // 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.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5.0, 5.0, 5.0, 5.0)); plot.setBackgroundPaint(Color.WHITE); plot.setOutlinePaint(null); 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()); rangeAxis.setLowerBound(0); rangeAxis.setAutoRange(true); final LineAndShapeRenderer renderer = (LineAndShapeRenderer) plot.getRenderer(); renderer.setBaseStroke(new BasicStroke(2.0f)); applyColorPalette(renderer); // crop extra space around the graph plot.setInsets(new RectangleInsets(5.0, 0, 0, 5.0)); return chart; }
From source file:org.jfree.chart.demo.DualAxisDemo.java
/** * Creates a new demo instance./*w w w . j av a 2 s.c o m*/ * * @param title the frame title. */ public DualAxisDemo(final String title) { super(title); final CategoryDataset dataset1 = createDataset1(); // create the chart... final JFreeChart chart = ChartFactory.createBarChart("Dual Axis Chart", // chart title "Category", // domain axis label "Value", // range axis label dataset1, // data PlotOrientation.VERTICAL, true, // include legend true, // tooltips? false // URL generator? Not required... ); // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... chart.setBackgroundPaint(Color.white); // chart.getLegend().setAnchor(Legend.SOUTH); // get a reference to the plot for further customisation... final CategoryPlot plot = chart.getCategoryPlot(); plot.setBackgroundPaint(new Color(0xEE, 0xEE, 0xFF)); plot.setDomainAxisLocation(AxisLocation.BOTTOM_OR_RIGHT); final CategoryDataset dataset2 = createDataset2(); plot.setDataset(1, dataset2); plot.mapDatasetToRangeAxis(1, 1); final CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setCategoryLabelPositions(CategoryLabelPositions.DOWN_45); final ValueAxis axis2 = new NumberAxis("Secondary"); plot.setRangeAxis(1, axis2); final LineAndShapeRenderer renderer2 = new LineAndShapeRenderer(); renderer2.setToolTipGenerator(new StandardCategoryToolTipGenerator()); plot.setRenderer(1, renderer2); plot.setDatasetRenderingOrder(DatasetRenderingOrder.REVERSE); // OPTIONAL CUSTOMISATION COMPLETED. // add the chart to a panel... final ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new java.awt.Dimension(500, 270)); setContentPane(chartPanel); }
From source file:br.ufba.eleicoestransparentes.view.chart.GraficoBarra.java
/** * Creates a sample chart./* www . ja va2 s . c o m*/ * * @param dataset the dataset. * * @return The chart. */ private JFreeChart createChart(final CategoryDataset dataset, String titulo) { // create the chart... final JFreeChart chart = ChartFactory.createBarChart(titulo, // chart title "Doador", // domain axis label "Valor", // range axis label dataset, // data PlotOrientation.VERTICAL, // orientation true, // include legend true, // tooltips? false // URLs? ); // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... // set the background color for the chart... chart.setBackgroundPaint(Color.white); // get a reference to the plot for further customisation... final CategoryPlot plot = chart.getCategoryPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); // set the range axis to display integers only... final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); // disable bar outlines... final BarRenderer renderer = (BarRenderer) plot.getRenderer(); renderer.setDrawBarOutline(false); // set up gradient paints for series... final GradientPaint gp0 = new GradientPaint(0.0f, 0.0f, Color.blue, 0.0f, 0.0f, Color.lightGray); renderer.setSeriesPaint(0, gp0); final CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 6.0)); // OPTIONAL CUSTOMISATION COMPLETED. return chart; }