List of usage examples for org.jfree.chart.axis CategoryLabelPositions UP_90
CategoryLabelPositions UP_90
To view the source code for org.jfree.chart.axis CategoryLabelPositions UP_90.
Click Source Link
From source file:pwm.visualizer.MDPPolicyPanel.java
private JFreeChart createChart() { NumberAxis nutritionAxis = new NumberAxis("Calories/Day"); nutritionAxis.setLowerBound(0);// w w w .j a va2 s .c o m nutritionAxis.setUpperBound(5000); nutritionAxis.setAutoRange(false); // CategoryPlot categoryplot = new CategoryPlot(nutritionDataSet, new CategoryAxis("Weight(KG)"), nutritionAxis, new BarRenderer()); CategoryAxis xaxis = categoryplot.getDomainAxis(); xaxis.setCategoryLabelPositions(CategoryLabelPositions.UP_90); LegendItemCollection legend = new LegendItemCollection(); LegendItem nutritionLegend = new LegendItem("Calories/Day"); LegendItem exerciseLegend = new LegendItem("Physical Activity Level"); nutritionLegend.setFillPaint(Color.BLUE); exerciseLegend.setFillPaint(Color.RED); legend.add(nutritionLegend); legend.add(exerciseLegend); categoryplot.setFixedLegendItems(legend); JFreeChart jfreechart = new JFreeChart("Policy Visualizer", categoryplot); categoryplot.setDataset(1, exerciseDataSet); categoryplot.mapDatasetToRangeAxis(1, 1); NumberAxis exerciseAxis = new NumberAxis("Physical Activity Level"); exerciseAxis.setLowerBound(0); exerciseAxis.setUpperBound(3.0); exerciseAxis.setAutoRange(false); categoryplot.setRangeAxis(1, exerciseAxis); BarRenderer barrenderer1 = new BarRenderer(); categoryplot.setRenderer(1, barrenderer1); // BarRenderer stackedbarrenderer = (BarRenderer)categoryplot.getRenderer(); // stackedbarrenderer.setDrawBarOutline(true); // stackedbarrenderer.setBaseItemLabelsVisible(false); // stackedbarrenderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator()); ChartUtilities.applyCurrentTheme(jfreechart); return jfreechart; }
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 );/* w w w. j av a 2 s .co 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.jgrasstools.gears.utils.chart.CategoryBoxplot.java
public JFreeChart getChart() { if (chart == null) { createDataset();/*from ww w.j ava2s .c o m*/ chart = ChartFactory.createBarChart(getTitle(), // 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); final BoxAndWhiskerRenderer renderer = new BoxAndWhiskerRenderer(); renderer.setFillBox(true); renderer.setToolTipGenerator(new BoxAndWhiskerToolTipGenerator()); renderer.setMeanVisible(isMeanVisible); plot.setRenderer(renderer); } return chart; }
From source file:com.sonyericsson.jenkins.plugins.bfa.graphs.StackedBarChart.java
@Override protected JFreeChart createGraph() { DefaultCategoryDataset dataset = createDataset(); JFreeChart chart = ChartFactory.createStackedBarChart(getTitle(), getXAxisTitle(), getYAxisTitle(), dataset, PlotOrientation.VERTICAL, true, true, false); final CategoryPlot plot = chart.getCategoryPlot(); int index = dataset.getRowIndex(NO_FAILURE); if (index >= 0) { plot.getRenderer().setSeriesVisibleInLegend(index, false); }/* www .j a v a 2s . c o m*/ CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_90); domainAxis.setCategoryMargin(0); final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); return chart; }
From source file:dk.sdu.mmmi.featureous.views.codecharacterization.TanglingViewChart.java
public TanglingViewChart(boolean pkg, boolean sortByValue) { this.sortByValue = sortByValue; this.pkg = pkg; data = new DefaultKeyedValues2DDataset(); String title = "Computational unit characterization"; jchart = ChartFactory.createStackedBarChart(title, (pkg) ? "Package" : "Class", "Tangling", data, PlotOrientation.VERTICAL, true, false, false); CategoryPlot plot = (CategoryPlot) jchart.getPlot(); // chart.getLegend().setPosition(RectangleEdge.RIGHT); // chart.getLegend().setVerticalAlignment(VerticalAlignment.TOP); // chart.getLegend().setHorizontalAlignment(HorizontalAlignment.LEFT); LegendItemCollection lic = new LegendItemCollection(); // lic.add(new LegendItem("Infrastructural unit", "", "", "", new Rectangle(10, 10), Color.GREEN)); // lic.add(new LegendItem("Group-feature unit", "", "", "", new Rectangle(10, 10), Color.BLUE)); // lic.add(new LegendItem("Single-feature unit", "", "", "", new Rectangle(10, 10), Color.RED)); plot.setFixedLegendItems(lic);/*ww w .ja va 2 s. co m*/ // chart.removeLegend(); plot.setDomainAxis(new SparselyLabeledCategoryAxis(20)); CategoryAxis xAxis = (CategoryAxis) plot.getDomainAxis(); xAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_90); xAxis.setLabel((pkg) ? "Package" : "Class"); // xAxis.setTickLabelInsets(new RectangleInsets(0, 0, 5, 5)); // xAxis.setMaximumCategoryLabelLines(1); xAxis.setLowerMargin(0); xAxis.setCategoryMargin(0); xAxis.setUpperMargin(0); // xAxis.setMaximumCategoryLabelWidthRatio(20f); jchart.setBackgroundPaint(Color.white); StackedBarRenderer renderer = new StackedBarRenderer() { @Override public void drawItem(Graphics2D g2, CategoryItemRendererState state, Rectangle2D dataArea, CategoryPlot plot, CategoryAxis domainAxis, ValueAxis rangeAxis, CategoryDataset dataset, int row, int column, int pass) { super.drawItem(g2, state, dataArea, plot, domainAxis, rangeAxis, dataset, row, column, pass); double start = plot.getDomainAxis().getCategoryStart(column, getColumnCount(), dataArea, plot.getDomainAxisEdge()); double end = plot.getDomainAxis().getCategoryEnd(column, getColumnCount(), dataArea, plot.getDomainAxisEdge()); String compUnit = data.getRowKey(row).toString(); // Calculate y coeffs double posBase = getBase(); // for(int i = 0; i<row; i++){ // Number val = dataset.getValue(i, column); // if(val!=null){ // posBase = posBase + val.doubleValue(); // } // } Number value = dataset.getValue(row, column); if (value == null) { return; } double val = value.doubleValue(); double translatedBase = plot.getRangeAxis().valueToJava2D(posBase, dataArea, plot.getRangeAxisEdge()); double translatedValue = plot.getRangeAxis().valueToJava2D(posBase + val, dataArea, plot.getRangeAxisEdge()); if (Controller.getInstance().getTraceSet().getSelectionManager().getSelectedClasses() .contains(compUnit) || Controller.getInstance().getTraceSet().getSelectionManager().getSelectedPkgs() .contains(compUnit)) { g2.setPaint(UIUtils.SELECTION_COLOR); g2.setStroke(new BasicStroke(3f)); Line2D l2d = new Line2D.Double(start, translatedBase, start, translatedValue); g2.draw(l2d); l2d = new Line2D.Double(end, translatedBase, end, translatedValue); g2.draw(l2d); l2d = new Line2D.Double(start, translatedBase, end, translatedBase); g2.draw(l2d); l2d = new Line2D.Double(start, translatedValue, end, translatedValue); g2.draw(l2d); } } }; renderer.setToolTipGenerator(new CategoryToolTipGenerator() { public String generateToolTip(CategoryDataset cd, int i, int i1) { String key = data.getRowKey(i).toString(); // key = key.substring(0, key.length()-1); return "<html>" + i + " - " + key + "<br>" + Double.toString(cd.getValue(i, i1).doubleValue()) + "</hmtl>"; } }); plot.setRenderer(renderer); panel = new ChartPanel(jchart); panel.getPopupMenu().setEnabled(false);//add(SVGExporter.createExportAction(chart, panel)); createView(); Controller.getInstance().getTraceSet().getSelectionManager().addSelectionListener(this); }
From source file:com.google.jenkins.flakyTestHandler.plugin.TestFlakyStatsOverRevision.java
private JFreeChart createChart(CategoryDataset dataset) { final JFreeChart chart = ChartFactory.createStackedAreaChart(null, // chart title null, // unused "count", // range axis label*/master dataset, // data PlotOrientation.VERTICAL, // orientation false, // include legend true, // tooltips false // urls );/*from w w w .jav a 2 s . com*/ chart.setBackgroundPaint(Color.white); final CategoryPlot plot = chart.getCategoryPlot(); plot.setBackgroundPaint(Color.WHITE); plot.setOutlinePaint(null); plot.setForegroundAlpha(0.8f); 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() { @Override public String generateToolTip(CategoryDataset dataset, int row, int column) { RevisionLabel label = (RevisionLabel) dataset.getColumnKey(column); Number value = dataset.getValue(row, column); switch (row) { case 0: return label.revision + ": " + value + " fails"; case 1: return label.revision + ": " + value + " passes"; default: return label.revision; } } }; plot.setRenderer(ar); ar.setSeriesPaint(0, ColorPalette.RED); // Fails. ar.setSeriesPaint(1, ColorPalette.BLUE); // Passes. // crop extra space around the graph plot.setInsets(new RectangleInsets(0, 0, 0, 5.0)); return chart; }
From source file:com.thalesgroup.hudson.plugins.cccc.CcccChartBuilder.java
protected JFreeChart createGraph() { JFreeChart chart = ChartFactory.createStackedAreaChart(null, null, "Number of modules", buildDataset(action), PlotOrientation.VERTICAL, true, false, true); chart.setBackgroundPaint(Color.white); CategoryPlot plot = chart.getCategoryPlot(); plot.setBackgroundPaint(Color.WHITE); plot.setOutlinePaint(null);// w ww . j av a 2 s. c o m plot.setForegroundAlpha(0.8f); 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); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); // crop extra space around the graph plot.setInsets(new RectangleInsets(0, 0, 0, 5.0)); CategoryItemRenderer firstRender = new DefaultCategoryItemRenderer(); CcccAreaRenderer renderer = new CcccAreaRenderer(action.getUrlName()); plot.setRenderer(firstRender); //Second NumberAxis axis2 = new NumberAxis("Lines of Code"); axis2.setLabelPaint(Color.BLUE); axis2.setAxisLinePaint(Color.BLUE); axis2.setTickLabelPaint(Color.BLUE); CategoryPlot categoryPlot = chart.getCategoryPlot(); categoryPlot.setRangeAxis(1, axis2); //CategoryAxis categoryAxis = categoryPlot.getDomainAxis(); categoryPlot.setDataset(1, buildDataset2(action)); categoryPlot.mapDatasetToRangeAxis(1, 1); CategoryItemRenderer rendu = new DefaultCategoryItemRenderer(); rendu.setBasePaint(Color.BLUE); categoryPlot.setRenderer(1, rendu); //Third NumberAxis axis3 = new NumberAxis("McCabe's Cyclomatic Number"); axis3.setLabelPaint(Color.GREEN); axis3.setAxisLinePaint(Color.GREEN); axis3.setTickLabelPaint(Color.GREEN); CategoryPlot categoryPlot3 = chart.getCategoryPlot(); categoryPlot3.setRangeAxis(2, axis3); categoryPlot3.setDataset(2, buildDataset3(action)); categoryPlot3.mapDatasetToRangeAxis(2, 2); categoryPlot3.mapDatasetToDomainAxis(2, 0); CategoryItemRenderer rendu3 = new DefaultCategoryItemRenderer(); rendu3.setBasePaint(Color.GREEN); categoryPlot3.setRenderer(2, rendu3); return chart; }
From source file:org.openfaces.component.chart.impl.PropertiesConverter.java
public static CategoryLabelPositions toCategroryLabelPosition(CategoryAxisLabelPosition position) { if (position == null) return CategoryLabelPositions.STANDARD; if (position.equals(CategoryAxisLabelPosition.UP_45)) return CategoryLabelPositions.UP_45; if (position.equals(CategoryAxisLabelPosition.UP_90)) return CategoryLabelPositions.UP_90; if (position.equals(CategoryAxisLabelPosition.DOWN_45)) return CategoryLabelPositions.DOWN_45; if (position.equals(CategoryAxisLabelPosition.DOWN_90)) return CategoryLabelPositions.DOWN_90; return CategoryLabelPositions.STANDARD; }
From source file:net.sf.jsfcomp.chartcreator.utils.ChartAxisUtils.java
public static void createCategorySeriesAxis(JFreeChart chart, ChartAxisData chartAxisData, int axisIndex) { CategoryPlot plot = chart.getCategoryPlot(); if (chartAxisData.isDomain()) { CategoryAxis axis = new CategoryAxis(chartAxisData.getLabel()); axis.setTickLabelsVisible(chartAxisData.isTickLabels()); axis.setTickMarksVisible(chartAxisData.isTickMarks()); if (chartAxisData.getTickLabelFontSize() > 0) { Font tickFont = CategoryAxis.DEFAULT_TICK_LABEL_FONT .deriveFont(chartAxisData.getTickLabelFontSize()); axis.setTickLabelFont(tickFont); }/* www.j a v a 2s.com*/ if (chartAxisData.isVerticalTickLabels()) { axis.setCategoryLabelPositions(CategoryLabelPositions.UP_90); } plot.setDomainAxis(plot.getDomainAxisCount() - 1, axis); } else { ValueAxis axis = createNumberAxis(chart, chartAxisData); axis.setTickLabelsVisible(chartAxisData.isTickLabels()); axis.setTickMarksVisible(chartAxisData.isTickMarks()); if (chartAxisData.getTickLabelFontSize() > 0) { Font tickFont = CategoryAxis.DEFAULT_TICK_LABEL_FONT .deriveFont(chartAxisData.getTickLabelFontSize()); axis.setTickLabelFont(tickFont); } plot.setRangeAxis(axis); } }
From source file:com.googlecode.refit.jenkins.ReFitGraph.java
/** * Creates a chart from the test result data set. * <p>/* w ww. j a v a2 s . c o m*/ * The i-th row of the data set corresponds to the results from the i-th build. * Each row has columns 0, 1, 2 containing the number of failed, skipped and passed tests. * The chart stacks these values from bottom to top, joins the values for the same columns * with lines and fills the areas between the lines with given colours. * <p> * TODO Find out if Jenkins core provides any caching for the chart or the data set. */ @Override protected JFreeChart createGraph() { final JFreeChart chart = ChartFactory.createStackedAreaChart(null, // chart title null, // domain axis label "count", // range axis label data, // data PlotOrientation.VERTICAL, // orientation false, // include legend true, // tooltips false // urls ); chart.setBackgroundPaint(Color.white); final CategoryPlot plot = chart.getCategoryPlot(); plot.setBackgroundPaint(Color.WHITE); plot.setOutlinePaint(null); plot.setForegroundAlpha(0.8f); 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(); ChartUtil.adjustChebyshev(data, rangeAxis); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); rangeAxis.setAutoRange(true); StackedAreaRenderer ar = new StackedAreaRenderer2() { private static final long serialVersionUID = 1L; /** * Colour brush for the given data point. */ @Override public Paint getItemPaint(int row, int column) { return super.getItemPaint(row, column); } /** * URL for the given data point, which gets opened when the user clicks on or near * the data point in the chart. */ @Override public String generateURL(CategoryDataset dataset, int row, int column) { ChartLabel label = (ChartLabel) dataset.getColumnKey(column); return label.getUrl(); } /** * Tooltip to be displayed on the chart when the user hovers at or near the * data point. * <p> * The tooltip has the format {@code #17 : 300 Passed}, indicating the build number * and the number of tests with the given result. */ @Override public String generateToolTip(CategoryDataset dataset, int row, int column) { ChartLabel label = (ChartLabel) dataset.getColumnKey(column); TestResult result = label.getResult(); String rowKey = (String) dataset.getRowKey(row); return result.getOwner().getDisplayName() + " : " + dataset.getValue(row, column) + " " + rowKey.substring(1); } }; plot.setRenderer(ar); // Define colours for the data points by column index ar.setSeriesPaint(0, ColorPalette.RED); // Failed ar.setSeriesPaint(1, ColorPalette.YELLOW); // Skipped ar.setSeriesPaint(2, ColorPalette.BLUE); // Passed // crop extra space around the graph plot.setInsets(new RectangleInsets(0, 0, 0, 5.0)); return chart; }