List of usage examples for org.jfree.chart.axis CategoryLabelPositions STANDARD
CategoryLabelPositions STANDARD
To view the source code for org.jfree.chart.axis CategoryLabelPositions STANDARD.
Click Source Link
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:ca.sqlpower.wabit.swingui.chart.ChartSwingUtil.java
/** * Creates a JFreeChart based on the current query results produced by the * given chart./*ww w .java 2 s.c o m*/ * * @param c * The chart from which to produce a JFreeChart component. Must * not be null. * @return A chart based on the data and settings in the given chart, or * null if the given chart is not sufficiently configured (for * example, if its type is not set) or it is currently unable to * produce a result set. */ public static JFreeChart createChartFromQuery(Chart c) throws SQLException, QueryInitializationException, InterruptedException { logger.debug("Creating JFreeChart for Wabit chart " + c); ChartType chartType = c.getType(); if (chartType == null) { logger.debug("Returning null (chart's type is not set)"); return null; } final JFreeChart chart; if (chartType.getDatasetType().equals(DatasetType.CATEGORY)) { JFreeChart categoryChart = createCategoryChart(c); logger.debug("Made a new category chart: " + categoryChart); if (categoryChart != null && categoryChart.getPlot() instanceof CategoryPlot) { double rotationRads = Math.toRadians(c.getXAxisLabelRotation()); CategoryLabelPositions clp; if (Math.abs(rotationRads) < 0.05) { clp = CategoryLabelPositions.STANDARD; } else if (rotationRads < 0) { clp = CategoryLabelPositions.createUpRotationLabelPositions(-rotationRads); } else { clp = CategoryLabelPositions.createDownRotationLabelPositions(rotationRads); } CategoryAxis domainAxis = categoryChart.getCategoryPlot().getDomainAxis(); domainAxis.setMaximumCategoryLabelLines(5); domainAxis.setCategoryLabelPositions(clp); } chart = categoryChart; } else if (chartType.getDatasetType().equals(DatasetType.XY)) { JFreeChart xyChart = createXYChart(c); logger.debug("Made a new XY chart: " + xyChart); chart = xyChart; } else { throw new IllegalStateException("Unknown chart dataset type " + chartType.getDatasetType()); } if (chart != null) { makeChartNice(chart); } return chart; }
From source file:sanger.team16.gui.genevar.eqtl.query.SNPGeneAssocPlot.java
private JFreeChart createChart(String populationName, CategoryDataset categoryDataset, double max, double min) { CategoryAxis categoryaxis = new CategoryAxis(); categoryaxis.setCategoryLabelPositions(CategoryLabelPositions.STANDARD); //categoryaxis.setMaximumCategoryLabelWidthRatio(5F); //categoryaxis.setMaximumCategoryLabelLines(141); //categoryaxis.setCategoryMargin(450); LineAndShapeRenderer lineandshaperenderer = new LineAndShapeRenderer(); lineandshaperenderer.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator()); lineandshaperenderer.setBaseShapesFilled(false); lineandshaperenderer.setBaseShape(ShapeUtilities.createDiamond((float) 3)); lineandshaperenderer.setBaseSeriesVisibleInLegend(false); //lineandshaperenderer.setBaseLinesVisible(false); lineandshaperenderer.setAutoPopulateSeriesShape(false); lineandshaperenderer.setAutoPopulateSeriesPaint(false); //lineandshaperenderer.findRangeBounds(categoryDataset); NumberAxis numberaxis = new NumberAxis("Expression"); numberaxis.setAutoRangeIncludesZero(false); //numberaxis.setRangeWithMargins(min, max); CategoryPlot categoryplot = new CategoryPlot(categoryDataset, categoryaxis, numberaxis, lineandshaperenderer);/*from ww w . java 2s .c o m*/ categoryplot.setDomainGridlinesVisible(false); categoryplot.setOrientation(PlotOrientation.VERTICAL); JFreeChart jfreechart = new JFreeChart(populationName, new Font("SansSerif", 1, 14), categoryplot, true); return jfreechart; }
From source file:jmemorize.gui.swing.panels.HistoryChartPanel.java
private void updateDataSet() { CalendarComparator comp = null;/*from w ww . j av a 2 s . c o m*/ switch (m_mode) { case SHOW_ALL: comp = LearnHistory.SIMPLE_COMP; break; case SHOW_BY_DATE: comp = LearnHistory.DATE_COMP; break; case SHOW_BY_WEEK: comp = LearnHistory.WEEK_COMP; break; case SHOW_BY_MONTH: comp = LearnHistory.MONTH_COMP; break; case SHOW_BY_YEAR: comp = LearnHistory.YEAR_COMP; break; } List<SessionSummary> summaries = m_history.getSummaries(comp, MAX_SESSIONS, true); // TODO make last argument optional DateFormat dateFormat = comp.getFormat(); CategoryPlot plot = (CategoryPlot) m_chart.getPlot(); plot.setDataset(0, createDataSet(summaries, dateFormat)); plot.setDataset(1, createMinutesDataSet(summaries, dateFormat)); CategoryLabelPositions pos = comp.showRotated() ? CategoryLabelPositions.UP_45 : CategoryLabelPositions.STANDARD; plot.getDomainAxis().setCategoryLabelPositions(pos); }
From source file:org.openmrs.module.vcttrac.web.view.chart.VCTCreateBarChartView.java
/** * Creates a sample chart.//from w w w .j a va2s . c o m * * @param dataset the dataset. * @return The chart. */ private JFreeChart createChart(CategoryDataset dataset, int typeOfChart) { String title = ""; if (typeOfChart == 1) title = VCTTracUtil.getMessage("vcttrac.graph.statistic.compare.todayandyesterday", null); else if (typeOfChart == 2) title = VCTTracUtil.getMessage("vcttrac.year", null) + " : " + (new Date().getYear() + 1900); else if (typeOfChart == 3) title = VCTTracUtil.getMessage("vcttrac.graph.statistic.years", null); // create the chart... JFreeChart chart = ChartFactory.createBarChart(title, null, null, // chart title dataset, // data PlotOrientation.VERTICAL, // orientation false, // 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... CategoryPlot plot = chart.getCategoryPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setDomainGridlinesVisible(true); plot.setRangeGridlinePaint(Color.white); Paint[] colors = createPaint(); CustomBarRenderer renderer = new CustomBarRenderer(colors); renderer.setGradientPaintTransformer( new StandardGradientPaintTransformer(GradientPaintTransformType.CENTER_HORIZONTAL)); plot.setRenderer(renderer); // set the range axis to display integers only... NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); rangeAxis.setUpperMargin(0.15); // CategoryItemRenderer renderer = plot.getRenderer(); renderer.setItemLabelGenerator(new StandardCategoryItemLabelGenerator()); renderer.setSeriesItemLabelsVisible(0, Boolean.TRUE); CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setTickLabelFont(new Font("Arial", Font.PLAIN, 12)); if (typeOfChart < 2) domainAxis.setCategoryLabelPositions(CategoryLabelPositions.STANDARD); else domainAxis.setCategoryLabelPositions(CategoryLabelPositions.DOWN_45); return chart; }
From source file:gg.view.overview.IncomeExpensesTopComponent.java
/** Displays the total income vs expenses for the current month */ public void displayData() { log.info("Income vs Expenses graph computed and displayed"); // Display hourglass cursor Utilities.changeCursorWaitStatus(true); // Create a dataset (the dataset will contain the plotted values) DefaultCategoryDataset dataset = new DefaultCategoryDataset(); // Create an empty chart JFreeChart chart = ChartFactory.createBarChart("", // chart title "", // x axis label NbBundle.getMessage(IncomeExpensesTopComponent.class, "IncomeExpensesTopComponent.Amount"), // y axis label dataset, // data displayed in the chart PlotOrientation.VERTICAL, false, // include legend true, // tooltips false // urls );//from w ww . ja va2 s . com // Update the chart color chart.setBackgroundPaint(jPanelIncomeExpenses.getBackground()); CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.setBackgroundPaint(Color.WHITE); // Set the orientation of the categories on the domain axis (X axis) CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setCategoryLabelPositions(CategoryLabelPositions.STANDARD); // Set the range axis (Y axis) to display integers only NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); // Set the bar renderer BarRenderer renderer = (BarRenderer) plot.getRenderer(); renderer.setDrawBarOutline(false); renderer.setMaximumBarWidth(0.1); GradientPaint gradientPaint = new GradientPaint(0.0f, 0.0f, new Color(49, 106, 196), 0.0f, 0.0f, Color.LIGHT_GRAY); renderer.setSeriesPaint(0, gradientPaint); // Create a period for the current month LocalDate today = new LocalDate(); Period currentMonth = new Period(Periods.getAdjustedStartDate(today, PeriodType.MONTH), Periods.getAdjustedEndDate(today, PeriodType.MONTH), PeriodType.MONTH); // Fill the dataset List<Currency> currencies = Wallet.getInstance().getActiveCurrencies(); for (Currency currency : currencies) { // Filter on the currency and on the current month SearchCriteria searchCriteria = new SearchCriteria(currency, null, currentMonth, null, null, null, false); // Get income BigDecimal currencyIncome = Datamodel.getIncome(searchCriteria); currencyIncome = currencyIncome.setScale(2, RoundingMode.HALF_EVEN); // Get expenses BigDecimal currencyExpenses = Datamodel.getExpenses(searchCriteria).abs(); currencyExpenses = currencyExpenses.setScale(2, RoundingMode.HALF_EVEN); // Plot income and expenses for the current month and for the current currency on the chart dataset.addValue(currencyIncome, currency.getName(), NbBundle.getMessage(IncomeExpensesTopComponent.class, "IncomeExpensesTopComponent.Income", new Object[] { currency })); dataset.addValue(currencyExpenses, currency.getName(), NbBundle.getMessage(IncomeExpensesTopComponent.class, "IncomeExpensesTopComponent.Expenses", new Object[] { currency })); } // Create the chart panel that contains the chart ChartPanel chartPanel = new ChartPanel(chart); // Display the chart jPanelIncomeExpenses.removeAll(); jPanelIncomeExpenses.add(chartPanel, BorderLayout.CENTER); // Display the normal cursor Utilities.changeCursorWaitStatus(false); }
From source file:com.xpn.xwiki.plugin.charts.params.DefaultChartParams2.java
void setAxis(String prefix) throws ParamException { set(prefix + AXIS_VISIBLE_SUFIX, Axis.DEFAULT_AXIS_VISIBLE); set(prefix + AXIS_LINE_VISIBLE_SUFFIX, Boolean.TRUE); set(prefix + AXIS_LINE_COLOR_SUFFIX, Axis.DEFAULT_AXIS_LINE_PAINT); set(prefix + AXIS_LINE_STROKE_SUFFIX, Axis.DEFAULT_AXIS_LINE_STROKE); set(prefix + AXIS_LABEL_SUFFIX, ""); // ? set(prefix + AXIS_LABEL_FONT_SUFFIX, Axis.DEFAULT_AXIS_LABEL_FONT); set(prefix + AXIS_LABEL_COLOR_SUFFIX, Axis.DEFAULT_AXIS_LABEL_PAINT); set(prefix + AXIS_LABEL_INSERTS_SUFFIX, Axis.DEFAULT_AXIS_LABEL_INSETS); set(prefix + AXIS_TICK_LABEL_VISIBLE_SUFFIX, new Boolean(Axis.DEFAULT_TICK_LABELS_VISIBLE)); set(prefix + AXIS_TICK_LABEL_FONT_SUFFIX, Axis.DEFAULT_TICK_LABEL_FONT); set(prefix + AXIS_TICK_LABEL_COLOR_SUFFIX, Axis.DEFAULT_TICK_LABEL_PAINT); set(prefix + AXIS_TICK_LABEL_INSERTS_SUFFIX, Axis.DEFAULT_TICK_LABEL_INSETS); set(prefix + AXIS_TICK_MARK_VISIBLE_SUFFIX, new Boolean(Axis.DEFAULT_TICK_MARKS_VISIBLE)); set(prefix + AXIS_TICK_MARK_INSIDE_LENGTH_SUFFIX, new Float(Axis.DEFAULT_TICK_MARK_INSIDE_LENGTH)); set(prefix + AXIS_TICK_MARK_OUTSIDE_LENGTH_SUFFIX, new Float(Axis.DEFAULT_TICK_MARK_OUTSIDE_LENGTH)); set(prefix + AXIS_TICK_MARK_COLOR_SUFFIX, Axis.DEFAULT_TICK_MARK_PAINT); set(prefix + AXIS_TICK_MARK_STROKE_SUFFIX, Axis.DEFAULT_TICK_MARK_STROKE); set(prefix + PLOTXY_AXIS_GRIDLINE_VISIBLE_SUFFIX, Boolean.TRUE); set(prefix + PLOTXY_AXIS_GRIDLINE_COLOR_SUFFIX, XYPlot.DEFAULT_GRIDLINE_PAINT); set(prefix + PLOTXY_AXIS_GRIDLINE_STROKE_SUFFIX, XYPlot.DEFAULT_GRIDLINE_STROKE); set(prefix + VALUE_AXIS_AUTO_RANGE_SUFFIX, new Boolean(ValueAxis.DEFAULT_AUTO_RANGE)); set(prefix + VALUE_AXIS_AUTO_RANGE_MIN_SIZE_SUFFIX, new Double(ValueAxis.DEFAULT_AUTO_RANGE_MINIMUM_SIZE)); set(prefix + VALUE_AXIS_AUTO_TICK_UNIT_SUFFIX, new Boolean(ValueAxis.DEFAULT_AUTO_TICK_UNIT_SELECTION)); set(prefix + VALUE_AXIS_LOWER_BOUND_SUFFIX, new Double(ValueAxis.DEFAULT_LOWER_BOUND)); set(prefix + VALUE_AXIS_UPPER_BOUND_SUFFIX, new Double(ValueAxis.DEFAULT_UPPER_BOUND)); set(prefix + AXIS_LOWER_MARGIN_SUFFIX, new Double(ValueAxis.DEFAULT_LOWER_MARGIN)); set(prefix + AXIS_UPPER_MARGIN_SUFFIX, new Double(ValueAxis.DEFAULT_UPPER_MARGIN)); set(prefix + VALUE_AXIS_VERTICAL_TICK_LABELS_SUFFIX, Boolean.FALSE); set(prefix + NUMBER_AXIS_AUTO_RANGE_INCLUDES_ZERO_SUFFIX, new Boolean(NumberAxis.DEFAULT_AUTO_RANGE_INCLUDES_ZERO)); set(prefix + NUMBER_AXIS_AUTO_RANGE_STICKY_ZERO_SUFFIX, new Boolean(NumberAxis.DEFAULT_AUTO_RANGE_STICKY_ZERO)); set(prefix + NUMBER_AXIS_RANGE_TYPE_SUFFIX, RangeType.FULL); set(prefix + NUMBER_AXIS_NUMBER_TICK_UNIT_SUFFIX, NumberAxis.DEFAULT_TICK_UNIT); set(prefix + NUMBER_AXIS_NUMBER_FORMAT_OVERRIDE_SUFFIX, (NumberFormat) null); set(prefix + DATE_AXIS_DATE_FORMAT_OVERRIDE_SUFFIX, (DateFormat) null); set(prefix + DATE_AXIS_LOWER_DATE_SUFFIX, DateAxis.DEFAULT_DATE_RANGE.getLowerDate()); set(prefix + DATE_AXIS_UPPER_DATE_SUFFIX, DateAxis.DEFAULT_DATE_RANGE.getUpperDate()); set(prefix + DATE_AXIS_DATE_TICK_MARK_POSITION_SUFFIX, DateTickMarkPosition.START); set(prefix + DATE_AXIS_DATE_TICK_UNIT_SUFFIX, DateAxis.DEFAULT_DATE_TICK_UNIT); set(prefix + CATEGORY_AXIS_CATEGORY_MARGIN_SUFFIX, new Double(CategoryAxis.DEFAULT_CATEGORY_MARGIN)); set(prefix + CATEGORY_AXIS_LABEL_POSITIONS_SUFFIX, CategoryLabelPositions.STANDARD); set(prefix + CATEGORY_AXIS_LABEL_POSITION_OFFSET_SUFFIX, new Integer(4)); set(prefix + CATEGORY_AXIS_MAXIMUM_LABEL_LINES_SUFFIX, new Integer(1)); set(prefix + CATEGORY_AXIS_MAXIMUM_LABEL_WIDTH_RATIO_SUFFIX, new Float(0.0f)); }
From source file:com.att.aro.ui.view.waterfalltab.WaterfallPanel.java
/** * @return the categoryAxis/* w w w. j a v a 2 s . c o m*/ */ private CategoryAxis getCategoryAxis() { if (categoryAxis == null) { categoryAxis = new CategoryAxis(); categoryAxis.setMaximumCategoryLabelWidthRatio(0.2f); categoryAxis.setCategoryLabelPositions(CategoryLabelPositions.replaceLeftPosition( CategoryLabelPositions.STANDARD, new CategoryLabelPosition(RectangleAnchor.LEFT, TextBlockAnchor.CENTER_LEFT, CategoryLabelWidthType.RANGE, 1.0f))); } return categoryAxis; }
From source file:org.jajuk.ui.views.StatView.java
/** * Collection size bars./*from w ww. ja va 2 s . co m*/ * * @return the chart */ private ChartPanel createCollectionSize() { try { final DateFormat additionFormatter = UtilString.getAdditionDateFormatter(); CategoryDataset cdata = null; JFreeChart jfchart = null; int iMonthsNumber = 5; // number of mounts we show, mounts // before are set together in 'before' long lSizeByMonth[] = new long[iMonthsNumber + 1]; // contains size ( in Go ) for each month, first cell is before // data int[] iMonths = getMonths(iMonthsNumber); ReadOnlyIterator<Track> tracks = TrackManager.getInstance().getTracksIterator(); while (tracks.hasNext()) { Track track = tracks.next(); int i = Integer.parseInt(additionFormatter.format(track.getDiscoveryDate())) / 100; for (int j = 0; j < iMonthsNumber + 1; j++) { if (i <= iMonths[j]) { lSizeByMonth[j] += track.getTotalSize(); } } } double[][] data = new double[1][iMonthsNumber + 1]; for (int i = 0; i < iMonthsNumber + 1; i++) { data[0][i] = (double) lSizeByMonth[i] / 1073741824; } cdata = DatasetUtilities.createCategoryDataset(new String[] { "" }, getMonthsLabels(iMonthsNumber), data); // chart, use local copy of method to use better format string for // tooltips jfchart = createBarChart3D(Messages.getString("StatView.7"), // chart // title Messages.getString("StatView.8"), // domain axis label Messages.getString("StatView.9"), // range axis label cdata, // data PlotOrientation.VERTICAL, // orientation false, // include legend true, // tooltips false, // urls "{1} = {2} GB"); CategoryPlot plot = jfchart.getCategoryPlot(); CategoryAxis axis = plot.getDomainAxis(); new CategoryLabelPosition(RectangleAnchor.TOP, TextBlockAnchor.TOP_RIGHT, TextAnchor.TOP_RIGHT, -Math.PI / 8.0, CategoryLabelWidthType.CATEGORY, 0); axis.setCategoryLabelPositions(CategoryLabelPositions.STANDARD); // set the background color for the chart... plot.setNoDataMessage(Messages.getString("StatView.10")); plot.setForegroundAlpha(0.5f); plot.setBackgroundAlpha(0.5f); // plot.setBackgroundImage(IconLoader.IMAGES_STAT_PAPER).getImage()); return new ChartPanel(jfchart); } catch (Exception e) { Log.error(e); return null; } }
From source file:net.sf.fspdfs.chartthemes.spring.AegeanChartTheme.java
/** * *//* ww w . j a v a 2s. c o m*/ protected JFreeChart createGanttChart() throws JRException { JFreeChart jfreeChart = super.createGanttChart(); CategoryPlot categoryPlot = (CategoryPlot) jfreeChart.getPlot(); categoryPlot.getDomainAxis().setCategoryLabelPositions(CategoryLabelPositions.STANDARD); categoryPlot.setDomainGridlinesVisible(true); categoryPlot.setDomainGridlinePosition(CategoryAnchor.END); categoryPlot.setDomainGridlineStroke( new BasicStroke(0.5f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 50, new float[] { 1 }, 0)); categoryPlot.setDomainGridlinePaint(ChartThemesConstants.GRAY_PAINT_217); categoryPlot.setRangeGridlinesVisible(true); categoryPlot.setRangeGridlineStroke( new BasicStroke(0.5f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 50, new float[] { 1 }, 0)); categoryPlot.setRangeGridlinePaint(ChartThemesConstants.GRAY_PAINT_217); // JRBarPlot barPlot = (BarPlot)categoryPlot; // categoryPlot.getDomainAxis().setTickLabelsVisible( // categoryPlot.getShowTickLabels() == null ? true : barPlot.getShowTickLabels(). // true // ); CategoryItemRenderer categoryRenderer = categoryPlot.getRenderer(); categoryRenderer.setBaseItemLabelsVisible(true); BarRenderer barRenderer = (BarRenderer) categoryRenderer; List seriesPaints = (List) getDefaultValue(defaultChartPropertiesMap, ChartThemesConstants.SERIES_COLORS); barRenderer.setSeriesPaint(0, (Paint) seriesPaints.get(3)); barRenderer.setSeriesPaint(1, (Paint) seriesPaints.get(0)); CategoryDataset categoryDataset = categoryPlot.getDataset(); if (categoryDataset != null) { for (int i = 0; i < categoryDataset.getRowCount(); i++) { barRenderer.setSeriesItemLabelFont(i, categoryPlot.getDomainAxis().getTickLabelFont()); barRenderer.setSeriesItemLabelsVisible(i, true); // barRenderer.setSeriesPaint(i, GRADIENT_PAINTS[i]); // CategoryMarker categoryMarker = new CategoryMarker(categoryDataset.getColumnKey(i),MARKER_COLOR, new BasicStroke(1f)); // categoryMarker.setAlpha(0.5f); // categoryPlot.addDomainMarker(categoryMarker, Layer.BACKGROUND); } } categoryPlot.setOutlinePaint(Color.DARK_GRAY); categoryPlot.setOutlineStroke(new BasicStroke(1.5f)); categoryPlot.setOutlineVisible(true); return jfreeChart; }