List of usage examples for org.jfree.chart.axis AxisLocation BOTTOM_OR_LEFT
AxisLocation BOTTOM_OR_LEFT
To view the source code for org.jfree.chart.axis AxisLocation BOTTOM_OR_LEFT.
Click Source Link
From source file:it.eng.spagobi.engines.kpi.bo.charttypes.dialcharts.BulletGraph.java
public JFreeChart createChart() { logger.debug("IN"); Number value = null;//from w w w .j a v a2 s . com if (dataset == null) { logger.debug("The dataset to be represented is null"); value = new Double(0); } else { value = dataset.getValue(); } DefaultCategoryDataset datasetC = new DefaultCategoryDataset(); datasetC.addValue(value, "", ""); // customize a bar chart JFreeChart chart = ChartFactory.createBarChart(null, null, null, datasetC, PlotOrientation.HORIZONTAL, false, false, false); chart.setBorderVisible(false); CategoryPlot plot = chart.getCategoryPlot(); plot.setOutlineVisible(true); plot.setOutlinePaint(Color.BLACK); plot.setInsets(new RectangleInsets(0.0, 0.0, 0.0, 0.0)); plot.setBackgroundPaint(null); plot.setDomainGridlinesVisible(false); plot.setRangeGridlinesVisible(false); plot.setRangeCrosshairVisible(false); plot.setAnchorValue(value.doubleValue()); // add the target marker if (target != null) { ValueMarker marker = new ValueMarker(target.doubleValue(), Color.BLACK, new BasicStroke(2.0f)); plot.addRangeMarker(marker, Layer.FOREGROUND); } //sets different marks for (Iterator iterator = intervals.iterator(); iterator.hasNext();) { KpiInterval interval = (KpiInterval) iterator.next(); // add the marks IntervalMarker marker = new IntervalMarker(interval.getMin(), interval.getMax(), interval.getColor()); plot.addRangeMarker(marker, Layer.BACKGROUND); logger.debug("Added new interval to the plot"); } // customize axes CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setVisible(false); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setVisible(show_axis); rangeAxis.setLabelFont(new Font("Arial", Font.PLAIN, 4)); // calculate the upper limit //double upperBound = target * upperFactor; rangeAxis.setRange(new Range(lower, upper)); plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT); // customize renderer BarRenderer renderer = (BarRenderer) plot.getRenderer(); renderer.setMaximumBarWidth(0.18); renderer.setSeriesPaint(0, Color.BLACK); /*BasicStroke d = new BasicStroke(3f,BasicStroke.CAP_ROUND ,BasicStroke.JOIN_ROUND); renderer.setSeriesOutlineStroke(0, d); renderer.setSeriesStroke(0, d); renderer.setStroke(d);*/ return chart; }
From source file:net.sourceforge.subsonic.controller.UserChartController.java
private JFreeChart createChart(CategoryDataset dataset, HttpServletRequest request) { JFreeChart chart = ChartFactory.createBarChart(null, null, null, dataset, PlotOrientation.HORIZONTAL, false, false, false);//from w ww . j a v a2 s. c o m CategoryPlot plot = chart.getCategoryPlot(); Paint background = new GradientPaint(0, 0, Color.lightGray, 0, IMAGE_MIN_HEIGHT, Color.white); plot.setBackgroundPaint(background); plot.setDomainGridlinePaint(Color.white); plot.setDomainGridlinesVisible(true); plot.setRangeGridlinePaint(Color.white); plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT); LogarithmicAxis rangeAxis = new LogarithmicAxis(null); rangeAxis.setStrictValuesFlag(false); rangeAxis.setAllowNegativesFlag(true); plot.setRangeAxis(rangeAxis); // Disable bar outlines. BarRenderer renderer = (BarRenderer) plot.getRenderer(); renderer.setDrawBarOutline(false); // Set up gradient paint for series. GradientPaint gp0 = new GradientPaint(0.0f, 0.0f, Color.blue, 0.0f, 0.0f, new Color(0, 0, 64)); renderer.setSeriesPaint(0, gp0); // Rotate labels. CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 6.0)); // Set theme-specific colors. Color bgColor = getBackground(request); Color fgColor = getForeground(request); chart.setBackgroundPaint(bgColor); domainAxis.setTickLabelPaint(fgColor); domainAxis.setTickMarkPaint(fgColor); domainAxis.setAxisLinePaint(fgColor); rangeAxis.setTickLabelPaint(fgColor); rangeAxis.setTickMarkPaint(fgColor); rangeAxis.setAxisLinePaint(fgColor); return chart; }
From source file:net.nosleep.superanalyzer.analysis.views.MostPlayedDGView.java
public JFreeChart createChart(String title, String domainLabel, DefaultCategoryDataset dataset) { JFreeChart chart = ChartFactory.createBarChart3D(title, // chart title domainLabel, // domain axis label Misc.getString("SONG_COUNT"), // range axis label dataset, // data PlotOrientation.HORIZONTAL, // orientation false, // include legend true, // tooltips? false // URLs? );//from ww w . j av a 2 s . co m // _artistChart.addSubtitle(HomePanel // .createSubtitle("How many songs you have in each genre")); CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); ChartUtilities.applyCurrentTheme(chart); Misc.formatChart(plot); plot.getDomainAxis().setMaximumCategoryLabelWidthRatio(0.5f); CategoryItemRenderer renderer = plot.getRenderer(); BarRenderer3D barRenderer = (BarRenderer3D) renderer; barRenderer.setWallPaint(Color.white); barRenderer.setSeriesPaint(0, Theme.getColorSet()[1]); return chart; }
From source file:com.opensourcestrategies.financials.reports.JFreeFinancialCharts.java
/** * Liquidity snapshot chart. Documentation is at http://www.opentaps.org/docs/index.php/Financials_Home_Screen * * Because a user might not have permission to view balances in all areas, this method takes into consideration * the ability to view various bars in the chart. * * @param accountsMap Map of accounts keyed by the glAccountType * @return String filename pointing to the chart, to be used with showChart URI request *///from w ww. j ava 2 s . c o m public static String createLiquiditySnapshotChart(Map<String, GenericValue> accountsMap, List<GenericValue> creditCardAccounts, Locale locale, boolean hasReceivablesPermission, boolean hasPayablesPermission, boolean hasInventoryPermission) throws GenericEntityException, IOException { Map<String, Object> uiLabelMap = UtilMessage.getUiLabels(locale); // create the dataset DefaultCategoryDataset dataset = new DefaultCategoryDataset(); // compile the four bars if (hasReceivablesPermission) { double cashBalance = 0.0; cashBalance += getPostedBalance(accountsMap.get("UNDEPOSITED_RECEIPTS")); cashBalance += getPostedBalance(accountsMap.get("BANK_STLMNT_ACCOUNT")); dataset.addValue(cashBalance, "", (String) uiLabelMap.get("FinancialsCashEquivalents")); double receivablesBalance = 0.0; receivablesBalance += getPostedBalance(accountsMap.get("ACCOUNTS_RECEIVABLE")); // merchant account settlement balances are receivable receivablesBalance += getPostedBalance(accountsMap.get("MRCH_STLMNT_ACCOUNT")); dataset.addValue(receivablesBalance, "", (String) uiLabelMap.get("FinancialsReceivables")); } if (hasInventoryPermission) { double inventoryBalance = 0.0; inventoryBalance += getPostedBalance(accountsMap.get("INVENTORY_ACCOUNT")); inventoryBalance += getPostedBalance(accountsMap.get("RAWMAT_INVENTORY")); inventoryBalance += getPostedBalance(accountsMap.get("WIP_INVENTORY")); dataset.addValue(inventoryBalance, "", (String) uiLabelMap.get("WarehouseInventory")); } if (hasPayablesPermission) { double payablesBalance = 0.0; payablesBalance += getPostedBalance(accountsMap.get("ACCOUNTS_PAYABLE")); payablesBalance += getPostedBalance(accountsMap.get("COMMISSIONS_PAYABLE")); payablesBalance += getPostedBalance(accountsMap.get("UNINVOICED_SHIP_RCPT")); dataset.addValue(payablesBalance, "", (String) uiLabelMap.get("FinancialsPayables")); } // set up the chart JFreeChart chart = ChartFactory.createBarChart((String) uiLabelMap.get("FinancialsLiquiditySnapshot"), // chart title null, // domain axis label null, // range axis label dataset, // data PlotOrientation.VERTICAL, // orientation false, // include legend true, // tooltips false // urls ); chart.setBackgroundPaint(Color.white); chart.setBorderVisible(true); chart.setPadding(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); // get a reference to the plot for further customisation... final CategoryPlot plot = chart.getCategoryPlot(); plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT); // get the bar renderer to put effects on the bars final BarRenderer renderer = (BarRenderer) plot.getRenderer(); renderer.setDrawBarOutline(false); // disable bar outlines // set up gradient paint on bar final GradientPaint gp = new GradientPaint(0.0f, 0.0f, Color.GREEN, 0.0f, 0.0f, Color.GRAY); renderer.setSeriesPaint(0, gp); // change the auto tick unit selection to integer units only... final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); // tilt the category labels so they fit CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 6.0)); // save as a png and return the file name return ServletUtilities.saveChartAsPNG(chart, 400, 300, null); }
From source file:net.nosleep.superanalyzer.analysis.views.MostPlayedAAView.java
public JFreeChart createChart(String title, String domainLabel, DefaultCategoryDataset dataset) { JFreeChart chart = ChartFactory.createBarChart3D(title, // chart title domainLabel, // domain axis label Misc.getString("SONG_COUNT"), // range axis label dataset, // data PlotOrientation.HORIZONTAL, // orientation false, // include legend true, // tooltips? false // URLs? );/*from ww w . ja v a 2 s . c o m*/ // _artistChart.addSubtitle(HomePanel // .createSubtitle("How many songs you have in each genre")); CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); ChartUtilities.applyCurrentTheme(chart); Misc.formatChart(plot); plot.getDomainAxis().setMaximumCategoryLabelWidthRatio(0.5f); CategoryItemRenderer renderer = plot.getRenderer(); BarRenderer3D barRenderer = (BarRenderer3D) renderer; barRenderer.setWallPaint(Color.white); barRenderer.setSeriesPaint(0, Theme.getColorSet()[1]); return chart; }
From source file:org.jstockchart.area.PriceArea.java
/** * Returns the price axis location that is determined by the plot * orientation.//www. ja v a2 s . c o m * * @return the price axis location. */ public AxisLocation getPriceAxisLocation() { PlotOrientation orientation = getOrientation(); AxisLocation result = null; if (orientation.equals(PlotOrientation.VERTICAL)) { result = AxisLocation.BOTTOM_OR_LEFT; } else if (orientation.equals(PlotOrientation.HORIZONTAL)) { result = AxisLocation.TOP_OR_RIGHT; } return result; }
From source file:net.nosleep.superanalyzer.analysis.views.GenreView.java
public void createChart() { _chart = ChartFactory.createBarChart3D(Misc.getString("GENRES"), // chart // title Misc.getString("GENRE"), // domain axis label Misc.getString("SONG_COUNT"), // range axis label _dataset, // data PlotOrientation.HORIZONTAL, // orientation false, // include legend true, // tooltips? false // URLs? );//w ww . j a va 2s. co m _chart.addSubtitle(HomePanel.createSubtitle(Misc.getString("GENRES_SUBTITLE"))); CategoryPlot plot = (CategoryPlot) _chart.getPlot(); plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); ChartUtilities.applyCurrentTheme(_chart); Misc.formatChart(plot); CategoryItemRenderer renderer = plot.getRenderer(); BarRenderer3D barRenderer = (BarRenderer3D) renderer; barRenderer.setWallPaint(Color.white); barRenderer.setSeriesPaint(0, Theme.getColorSet()[1]); }
From source file:r2d2e.solution.moduloteste.teste.GraficoD2.java
/** * Creates a combined chart./*from ww w . j a v a2s . co m*/ * * @return the combined chart. */ private JFreeChart createCombinedChart() { // create subplot 1... final XYDataset data1 = collection; final XYItemRenderer renderer1 = new StandardXYItemRenderer(); final NumberAxis rangeAxis1 = new NumberAxis("Nvel (cm)"); 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 = collection2; final XYItemRenderer renderer2 = new StandardXYItemRenderer(); final NumberAxis rangeAxis2 = new NumberAxis("Tenso (volts)"); final XYPlot subplot2 = new XYPlot(data2, null, rangeAxis2, renderer2); subplot2.setRangeAxisLocation(AxisLocation.TOP_OR_LEFT); // create subplot 3... final XYDataset data3 = collection3; final XYItemRenderer renderer3 = new StandardXYItemRenderer(); final NumberAxis rangeAxis3 = new NumberAxis("Tenso (volts)"); final XYPlot subplot3 = new XYPlot(data3, null, rangeAxis3, renderer3); subplot3.setRangeAxisLocation(AxisLocation.TOP_OR_LEFT); // parent plot... final CombinedDomainXYPlot plot = new CombinedDomainXYPlot(new NumberAxis("Tempo")); plot.setGap(10.0); // add the subplots... plot.add(subplot1, 1); plot.add(subplot2, 1); plot.add(subplot3, 1); plot.setOrientation(PlotOrientation.VERTICAL); // return a new chart containing the overlaid plot... return new JFreeChart("Grficos", JFreeChart.DEFAULT_TITLE_FONT, plot, true); }
From source file:org.jfree.chart.demo.MultipleAxisDemo1.java
/** * Creates the demo chart./*from ww w . j a v a 2 s . co m*/ * * @return The chart. */ private JFreeChart createChart() { final XYDataset dataset1 = createDataset("Series 1", 100.0, new Minute(), 200); final JFreeChart chart = ChartFactory.createTimeSeriesChart("Multiple Axis Demo 1", "Time of Day", "Primary Range Axis", dataset1, true, true, false); chart.setBackgroundPaint(Color.white); chart.addSubtitle(new TextTitle("Four datasets and four range axes.")); final XYPlot plot = chart.getXYPlot(); plot.setOrientation(PlotOrientation.VERTICAL); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); // plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5.0, 5.0, 5.0, 5.0)); final StandardXYItemRenderer renderer = (StandardXYItemRenderer) plot.getRenderer(); renderer.setPaint(Color.black); // AXIS 2 final NumberAxis axis2 = new NumberAxis("Range Axis 2"); axis2.setAutoRangeIncludesZero(false); axis2.setLabelPaint(Color.red); axis2.setTickLabelPaint(Color.red); plot.setRangeAxis(1, axis2); plot.setRangeAxisLocation(1, AxisLocation.BOTTOM_OR_LEFT); final XYDataset dataset2 = createDataset("Series 2", 1000.0, new Minute(), 170); plot.setDataset(1, dataset2); plot.mapDatasetToRangeAxis(1, 1); XYItemRenderer renderer2 = new StandardXYItemRenderer(); renderer2.setSeriesPaint(0, Color.red); plot.setRenderer(1, renderer2); // AXIS 3 final NumberAxis axis3 = new NumberAxis("Range Axis 3"); axis3.setLabelPaint(Color.blue); axis3.setTickLabelPaint(Color.blue); plot.setRangeAxis(2, axis3); final XYDataset dataset3 = createDataset("Series 3", 10000.0, new Minute(), 170); plot.setDataset(2, dataset3); plot.mapDatasetToRangeAxis(2, 2); XYItemRenderer renderer3 = new StandardXYItemRenderer(); renderer3.setSeriesPaint(0, Color.blue); plot.setRenderer(2, renderer3); // AXIS 4 final NumberAxis axis4 = new NumberAxis("Range Axis 4"); axis4.setLabelPaint(Color.green); axis4.setTickLabelPaint(Color.green); plot.setRangeAxis(3, axis4); final XYDataset dataset4 = createDataset("Series 4", 25.0, new Minute(), 200); plot.setDataset(3, dataset4); plot.mapDatasetToRangeAxis(3, 3); XYItemRenderer renderer4 = new StandardXYItemRenderer(); renderer4.setSeriesPaint(0, Color.green); plot.setRenderer(3, renderer4); return chart; }
From source file:com.att.aro.ui.view.diagnostictab.CreateBarPlot.java
public XYPlot drawXYItemPlot() { // Set up renderer XYItemRenderer throughputRenderer = new StandardXYItemRenderer(); throughputRenderer.setSeriesPaint(0, Color.red); // Normalize the throughput axis so that it represents max value NumberAxis axis = new NumberAxis(); axis.setVisible(false);/* w ww . j av a 2 s . c om*/ // Create plot XYPlot throughputPlot = new XYPlot(null, null, axis, throughputRenderer); throughputPlot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT); throughputPlot.getRangeAxis().setVisible(false); return throughputPlot; }