List of usage examples for org.jfree.chart.axis AxisLocation TOP_OR_LEFT
AxisLocation TOP_OR_LEFT
To view the source code for org.jfree.chart.axis AxisLocation TOP_OR_LEFT.
Click Source Link
From source file:pt.ist.expenditureTrackingSystem.presentationTier.actions.statistics.ChartGenerator.java
protected static JFreeChart createBarChart(final CategoryDataset categoryDataset, final String title) { final JFreeChart chart = ChartFactory.createBarChart3D(title, "", "", categoryDataset, PlotOrientation.VERTICAL, true, true, false); chart.setBackgroundPaint(new Color(0xF5, 0xF5, 0xF5)); final CategoryPlot plot = chart.getCategoryPlot(); plot.setRangeAxisLocation(AxisLocation.TOP_OR_LEFT); final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); return chart; }
From source file:de.fub.maps.project.detector.model.inference.ui.charts.ClassificationBarChart.java
/** * Creates new form ClassificationBarChart */// ww w. java 2 s. com public ClassificationBarChart() { super(); initComponents(); plot = new CustomCategoryPlot(); barChart = new JFreeChart(NbBundle.getMessage(ClassificationBarChart.class, "CLT_Chart_Classify_Name"), null, plot, true); ChartFactory.getChartTheme().apply(barChart); plot.setDomainAxis(new CategoryAxis()); plot.getDomainAxis().setLabel(NbBundle.getMessage(ClassificationBarChart.class, "CLT_Doman_Axis_Name")); plot.setOrientation(PlotOrientation.VERTICAL); Font font = new JLabel().getFont().deriveFont(Font.BOLD, 14); barChart.getTitle().setFont(font); barChart.getTitle().setPaint(new Color(153, 153, 153)); plot.setDataset(0, relDataset); plot.setDataset(1, absDataset); plot.mapDatasetToRangeAxis(0, 0); plot.mapDatasetToRangeAxis(1, 1); NumberAxis relAxis = new NumberAxis( NbBundle.getMessage(ClassificationBarChart.class, "CLT_Value_Axis_Name")); relAxis.setAutoRange(true); relAxis.setUpperMargin(.20); NumberAxis absAxis = new NumberAxis( NbBundle.getMessage(ClassificationBarChart.class, "CLT_Value_Rel_Axis_Name")); absAxis.setAutoRange(true); absAxis.setUpperMargin(.20); plot.setRangeAxis(0, relAxis); plot.setRangeAxis(1, absAxis); plot.setRangeAxisLocation(0, AxisLocation.TOP_OR_LEFT); plot.setRangeAxisLocation(1, AxisLocation.TOP_OR_RIGHT); BarRenderer relRenderer = new BarRenderer(); relRenderer.setBasePaint(relColor); relRenderer.setAutoPopulateSeriesPaint(false); relRenderer.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator()); relRenderer.setBarPainter(new StandardBarPainter()); relRenderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator( StandardCategoryItemLabelGenerator.DEFAULT_LABEL_FORMAT_STRING, new CustomNumberFormat())); relRenderer.setBaseItemLabelsVisible(true); BarRenderer absRenderer = new BarRenderer(); absRenderer.setBasePaint(absColor); absRenderer.setAutoPopulateSeriesPaint(false); absRenderer.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator()); absRenderer.setBarPainter(new StandardBarPainter()); absRenderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator( StandardCategoryItemLabelGenerator.DEFAULT_LABEL_FORMAT_STRING, new CustomNumberFormat())); absRenderer.setBaseItemLabelsVisible(true); plot.setRenderer(0, relRenderer); plot.setRenderer(1, absRenderer); plot.setBackgroundPaint(Color.white); barChart.setBackgroundPaint(Color.white); plot.setRangeGridlinesVisible(false); chartPanel = new ChartPanel(barChart, false); chartPanel.setVerticalAxisTrace(false); chartPanel.setDisplayToolTips(true); chartPanel.setBackground(Color.white); add(chartPanel, BorderLayout.CENTER); }
From source file:net.sf.maltcms.chromaui.charts.tools.ChartTools.java
/** * * @param plot * @return */ public static XYPlot getPlot2(XYPlot plot) { plot.setDomainAxisLocation(AxisLocation.TOP_OR_LEFT); return plot; }
From source file:org.jfree.chart.demo.CombinedXYPlotDemo1.java
/** * Creates a combined chart.// ww w . ja va 2 s . c om * * @return the combined chart. */ private JFreeChart createCombinedChart() { // create subplot 1... final XYDataset data1 = createDataset1(); final XYItemRenderer renderer1 = new StandardXYItemRenderer(); final NumberAxis rangeAxis1 = new NumberAxis("Range 1"); final XYPlot subplot1 = new XYPlot(data1, null, rangeAxis1, renderer1); subplot1.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT); final XYTextAnnotation annotation = new XYTextAnnotation("Hello!", 50.0, 10000.0); annotation.setFont(new Font("SansSerif", Font.PLAIN, 9)); annotation.setRotationAngle(Math.PI / 4.0); subplot1.addAnnotation(annotation); // create subplot 2... final XYDataset data2 = createDataset2(); final XYItemRenderer renderer2 = new StandardXYItemRenderer(); final NumberAxis rangeAxis2 = new NumberAxis("Range 2"); rangeAxis2.setAutoRangeIncludesZero(false); final XYPlot subplot2 = new XYPlot(data2, null, rangeAxis2, renderer2); subplot2.setRangeAxisLocation(AxisLocation.TOP_OR_LEFT); // parent plot... final CombinedDomainXYPlot plot = new CombinedDomainXYPlot(new NumberAxis("Domain")); plot.setGap(10.0); // add the subplots... plot.add(subplot1, 1); plot.add(subplot2, 1); plot.setOrientation(PlotOrientation.VERTICAL); // return a new chart containing the overlaid plot... return new JFreeChart("CombinedDomainXYPlot Demo", JFreeChart.DEFAULT_TITLE_FONT, plot, true); }
From source file:org.codehaus.mojo.chronos.chart.HistoryChartGenerator.java
public final void createGcChart(HistoricSamples samples, String dataId) throws IOException { XYPlot xyplot1 = newPlot(samples.getGcRatio(dataId), "chronos.label.gc.ratio", true); xyplot1.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT); xyplot1.getRenderer().setSeriesPaint(0, Color.GREEN); xyplot1.getRangeAxis().setStandardTickUnits(NumberAxis.createStandardTickUnits()); XYPlot xyplot2 = newPlot(samples.getKbCollectedPrSecond(dataId), "chronos.label.gc.kbpersec", true); xyplot2.setRangeAxisLocation(AxisLocation.TOP_OR_LEFT); xyplot2.getRenderer().setSeriesPaint(0, Color.GRAY); xyplot2.getRangeAxis().setStandardTickUnits(NumberAxis.createStandardTickUnits()); String timeLabel = bundle.getString("chronos.label.gc.historytime"); DateAxis timeAxis = ChartUtil.createTimeAxis(timeLabel, new SimpleDateFormat()); XYPlot combinedPlot = ChartUtil.createCombinedPlot(timeAxis, xyplot1, xyplot2); // xyplot1.setDomainAxis( timeAxis ); // XYPlot combinedPlot = xyplot1; JFreeChart chart = new JFreeChart(bundle.getString("chronos.label.gc"), combinedPlot); renderer.renderChart("history-gc-" + dataId, chart); }
From source file:com.yahoo.egads.utilities.GUIUtils.java
/** * Creates a combined chart./*from ww w.j av a 2s. co m*/ * * @return The combined chart. */ private JFreeChart createCombinedChart(DataSequence tsOne, DataSequence tsTwo, ArrayList<Anomaly> anomalyList) { // create subplot 1. final XYDataset data1 = createDataset(tsOne, "Original"); final XYItemRenderer renderer1 = new StandardXYItemRenderer(); final NumberAxis rangeAxis1 = new NumberAxis("Original Value"); XYPlot subplot1 = new XYPlot(data1, null, rangeAxis1, renderer1); subplot1.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT); // plot anomalies on subplot 1. addAnomalies(subplot1, anomalyList); // create subplot 2. final XYDataset data2 = createDataset(tsTwo, "Forecast"); final XYItemRenderer renderer2 = new StandardXYItemRenderer(); final NumberAxis rangeAxis2 = new NumberAxis("Forecast Value"); rangeAxis2.setAutoRangeIncludesZero(false); final XYPlot subplot2 = new XYPlot(data2, null, rangeAxis2, renderer2); subplot2.setRangeAxisLocation(AxisLocation.TOP_OR_LEFT); // parent plot. final CombinedDomainXYPlot plot = new CombinedDomainXYPlot(new NumberAxis("Time")); plot.setGap(10.0); // add the subplots. plot.add(subplot1, 1); plot.add(subplot2, 1); // Add anomaly score time-series. addAnomalyTS(plot, tsOne, tsTwo); plot.setOrientation(PlotOrientation.VERTICAL); // return a new chart containing the overlaid plot. return new JFreeChart("EGADS GUI", JFreeChart.DEFAULT_TITLE_FONT, plot, true); }
From source file:org.jfree.chart.demo.CombinedXYPlotDemo4.java
/** * Creates a combined chart.//www. j ava 2 s .c o m * * @return The combined chart. */ private JFreeChart createCombinedChart() { // create subplot 1... final XYDataset data1 = createDataset1(); final XYItemRenderer renderer1 = new StandardXYItemRenderer(); final NumberAxis rangeAxis1 = new NumberAxis("Range 1"); final XYPlot subplot1 = new XYPlot(data1, null, rangeAxis1, renderer1); subplot1.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT); // add secondary axis subplot1.setDataset(1, createDataset2()); final NumberAxis axis2 = new NumberAxis("Range Axis 2"); axis2.setAutoRangeIncludesZero(false); subplot1.setRangeAxis(1, axis2); subplot1.setRangeAxisLocation(1, AxisLocation.BOTTOM_OR_RIGHT); subplot1.setRenderer(1, new StandardXYItemRenderer()); subplot1.mapDatasetToRangeAxis(1, 1); final XYTextAnnotation annotation = new XYTextAnnotation("Hello!", 50.0, 10000.0); annotation.setFont(new Font("SansSerif", Font.PLAIN, 9)); annotation.setRotationAngle(Math.PI / 4.0); subplot1.addAnnotation(annotation); // create subplot 2... final XYDataset data2 = createDataset2(); final XYItemRenderer renderer2 = new StandardXYItemRenderer(); final NumberAxis rangeAxis2 = new NumberAxis("Range 2"); rangeAxis2.setAutoRangeIncludesZero(false); final XYPlot subplot2 = new XYPlot(data2, null, rangeAxis2, renderer2); subplot2.setRangeAxisLocation(AxisLocation.TOP_OR_LEFT); // parent plot... final CombinedDomainXYPlot plot = new CombinedDomainXYPlot(new NumberAxis("Domain")); plot.setGap(10.0); // add the subplots... plot.add(subplot1, 1); plot.add(subplot2, 1); plot.setOrientation(PlotOrientation.VERTICAL); // return a new chart containing the overlaid plot... return new JFreeChart("CombinedDomainXYPlot Demo", JFreeChart.DEFAULT_TITLE_FONT, plot, true); }
From source file:org.codehaus.mojo.chronos.chart.SummaryThroughputChartSource.java
private XYPlot createThreadCountPlot(ResourceBundle bundle, ReportConfig config) { TimeSeriesCollection dataset2 = createThreadCountdataset(bundle, config); String label = bundle.getString("chronos.label.threadcount.y"); XYPlot threadCountPlot = ChartUtil.newPlot(dataset2, label, false); threadCountPlot.setRangeAxisLocation(AxisLocation.TOP_OR_LEFT); threadCountPlot.getRenderer().setSeriesPaint(0, Color.GRAY); return threadCountPlot; }
From source file:daylightchart.daylightchart.chart.DaylightChart.java
private void adjustForChartOrientation(final ChartOrientation chartOrientation) { if (chartOrientation == null) { return;//from w w w . j ava 2 s. c om } final XYPlot plot = getXYPlot(); final ValueAxis hoursAxis = plot.getRangeAxis(); final ValueAxis monthsAxis = plot.getDomainAxis(); switch (chartOrientation) { case STANDARD: hoursAxis.setInverted(true); plot.setDomainAxisLocation(AxisLocation.TOP_OR_LEFT); break; case CONVENTIONAL: break; case VERTICAL: plot.setOrientation(PlotOrientation.HORIZONTAL); monthsAxis.setInverted(true); break; default: break; } }
From source file:edu.jhuapl.graphs.jfreechart.JFreeChartCategoryGraphSource.java
@Override public void initialize() throws GraphException { String title = getParam(GraphSource.GRAPH_TITLE, String.class, DEFAULT_TITLE); String xLabel = getParam(GraphSource.GRAPH_X_LABEL, String.class, DEFAULT_DOMAIN_LABEL); String yLabel = getParam(GraphSource.GRAPH_Y_LABEL, String.class, DEFAULT_RANGE_LABEL); CategoryDataset dataset = makeDataSet(); chart = createChart(title, xLabel, yLabel, dataset, false, false); // start customizing the graph Paint backgroundColor = getParam(GraphSource.BACKGROUND_COLOR, Paint.class, DEFAULT_BACKGROUND_COLOR); Paint plotColor = getParam(JFreeChartTimeSeriesGraphSource.PLOT_COLOR, Paint.class, backgroundColor); Double offset = getParam(GraphSource.AXIS_OFFSET, Double.class, DEFAULT_AXIS_OFFSET); Paint graphDomainGridlinePaint = getParam(GraphSource.GRAPH_DOMAIN_GRIDLINE_PAINT, Paint.class, backgroundColor);/*from ww w .j av a 2 s. c o m*/ Paint graphRangeGridlinePaint = getParam(GraphSource.GRAPH_RANGE_GRIDLINE_PAINT, Paint.class, backgroundColor); boolean graphBorder = getParam(GraphSource.GRAPH_BORDER, Boolean.class, DEFAULT_GRAPH_BORDER); chart.setBackgroundPaint(backgroundColor); CategoryPlot plot = chart.getCategoryPlot(); plot.setBackgroundPaint(plotColor); plot.setAxisOffset(new RectangleInsets(offset, offset, offset, offset)); plot.setDomainGridlinePaint(graphDomainGridlinePaint); plot.setDomainGridlinesVisible(true); plot.setRangeGridlinePaint(graphRangeGridlinePaint); plot.setOutlineVisible(graphBorder); // set the axis location AxisLocation axisLocation = getParam(GraphSource.GRAPH_RANGE_AXIS_LOCATION, AxisLocation.class, AxisLocation.TOP_OR_LEFT); plot.setRangeAxisLocation(axisLocation); // customize the y-axis if (params.get(RANGE_AXIS) instanceof ValueAxis) { ValueAxis valueAxis = (ValueAxis) params.get(RANGE_AXIS); plot.setRangeAxis(valueAxis); } ValueAxis valueAxis = plot.getRangeAxis(); Object yAxisFont = params.get(GraphSource.GRAPH_Y_AXIS_FONT); Object yAxisLabelFont = params.get(GraphSource.GRAPH_Y_AXIS_LABEL_FONT); Double rangeLowerBound = getParam(GraphSource.GRAPH_RANGE_LOWER_BOUND, Double.class, null); Double rangeUpperBound = getParam(GraphSource.GRAPH_RANGE_UPPER_BOUND, Double.class, null); boolean graphRangeIntegerTick = getParam(GraphSource.GRAPH_RANGE_INTEGER_TICK, Boolean.class, false); boolean graphRangeMinorTickVisible = getParam(GraphSource.GRAPH_RANGE_MINOR_TICK_VISIBLE, Boolean.class, true); if (yAxisFont instanceof Font) { valueAxis.setTickLabelFont((Font) yAxisFont); } if (yAxisLabelFont instanceof Font) { valueAxis.setLabelFont((Font) yAxisLabelFont); } if (rangeLowerBound != null) { valueAxis.setLowerBound(rangeLowerBound); } if (rangeUpperBound != null) { valueAxis.setUpperBound(rangeUpperBound); } if (graphRangeIntegerTick) { valueAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); } valueAxis.setMinorTickMarksVisible(graphRangeMinorTickVisible); // customize the x-axis if (params.get(DOMAIN_AXIS) instanceof CategoryAxis) { CategoryAxis domainAxis = (CategoryAxis) params.get(DOMAIN_AXIS); plot.setDomainAxis(domainAxis); } CategoryAxis domainAxis = plot.getDomainAxis(); Object xAxisFont = params.get(GraphSource.GRAPH_X_AXIS_FONT); Object xAxisLabelFont = params.get(GraphSource.GRAPH_X_AXIS_LABEL_FONT); if (xAxisFont instanceof Font) { domainAxis.setTickLabelFont((Font) xAxisFont); } if (xAxisLabelFont instanceof Font) { domainAxis.setLabelFont((Font) xAxisLabelFont); } domainAxis.setLabel(xLabel); domainAxis.setLowerMargin(0.0); domainAxis.setUpperMargin(0.0); plot.setDomainAxis(domainAxis); // change the font of the graph title Font titleFont = getParam(GraphSource.GRAPH_FONT, Font.class, DEFAULT_GRAPH_TITLE_FONT); TextTitle textTitle = new TextTitle(); textTitle.setText(title); textTitle.setFont(titleFont); chart.setTitle(textTitle); // makes a wrapper for the legend to remove the border around it boolean legend = getParam(GraphSource.GRAPH_LEGEND, Boolean.class, DEFAULT_GRAPH_LEGEND); boolean legendBorder = getParam(GraphSource.LEGEND_BORDER, Boolean.class, DEFAULT_LEGEND_BORDER); Object legendFont = params.get(GraphSource.LEGEND_FONT); if (legend) { LegendTitle legendTitle = new LegendTitle(chart.getPlot()); BlockContainer wrapper = new BlockContainer(new BorderArrangement()); if (legendBorder) { wrapper.setFrame(new BlockBorder(1, 1, 1, 1)); } else { wrapper.setFrame(new BlockBorder(0, 0, 0, 0)); } BlockContainer items = legendTitle.getItemContainer(); items.setPadding(2, 10, 5, 2); wrapper.add(items); legendTitle.setWrapper(wrapper); legendTitle.setPosition(RectangleEdge.BOTTOM); legendTitle.setHorizontalAlignment(HorizontalAlignment.CENTER); if (legendFont instanceof Font) { legendTitle.setItemFont((Font) legendFont); } chart.addSubtitle(legendTitle); } this.initialized = true; }