Search in sources :

Example 21 with CategoryPlot

use of org.jfree.chart.plot.CategoryPlot in project adempiere by adempiere.

the class CRPDetail method createChart.

/**
	 * Create Chart based on UOM
	 * 
	 * @param dataset
	 * @param title
	 * @param uom
	 * @return JFreeChart Chart based On UOM
	 */
public JFreeChart createChart(CategoryDataset dataset, String title, MUOM uom) {
    JFreeChart chart = ChartFactory.createBarChart3D(title, // X-Axis label
    Msg.translate(Env.getCtx(), "Day"), Msg.translate(Env.getCtx(), // Y-Axis
    (uom == null) ? "" : uom.getName()), // Dataset
    dataset, // orientation
    PlotOrientation.VERTICAL, // include legend
    true, // tooltips?
    true, // URLs?
    false);
    chart.setBackgroundPaint(Color.WHITE);
    chart.setAntiAlias(true);
    chart.setBorderVisible(true);
    CategoryPlot plot = chart.getCategoryPlot();
    plot.setRangeGridlinesVisible(true);
    plot.setRangeGridlinePaint(Color.GRAY);
    plot.setDomainGridlinesVisible(true);
    plot.setDomainGridlinePaint(Color.GRAY);
    BarRenderer3D barrenderer = (BarRenderer3D) plot.getRenderer();
    barrenderer.setDrawBarOutline(false);
    barrenderer.setBaseItemLabelGenerator(new LabelGenerator());
    barrenderer.setBaseItemLabelsVisible(true);
    barrenderer.setSeriesPaint(0, new Color(10, 80, 150, 128));
    barrenderer.setSeriesPaint(1, new Color(180, 60, 50, 128));
    ItemLabelPosition itemlabelposition = new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.TOP_CENTER);
    barrenderer.setPositiveItemLabelPosition(itemlabelposition);
    CategoryAxis domainAxis = plot.getDomainAxis();
    domainAxis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 6.0));
    return chart;
}
Also used : BarRenderer3D(org.jfree.chart.renderer.category.BarRenderer3D) CategoryAxis(org.jfree.chart.axis.CategoryAxis) Color(java.awt.Color) ItemLabelPosition(org.jfree.chart.labels.ItemLabelPosition) JFreeChart(org.jfree.chart.JFreeChart) CategoryPlot(org.jfree.chart.plot.CategoryPlot) StandardCategoryItemLabelGenerator(org.jfree.chart.labels.StandardCategoryItemLabelGenerator)

Example 22 with CategoryPlot

use of org.jfree.chart.plot.CategoryPlot in project bamboobsc by billchen198318.

the class CommonBarChartAction method fillChart.

private void fillChart(String title, String categoryLabel, String valueLabel, List<String> names, List<Float> values, List<String> colors, boolean horizontal) throws Exception {
    DefaultCategoryDataset data = new DefaultCategoryDataset();
    for (int ix = 0; ix < names.size(); ix++) {
        data.addValue(values.get(ix), "", names.get(ix));
    }
    this.chart = ChartFactory.createBarChart3D(// title
    title, categoryLabel, valueLabel, data, (horizontal ? PlotOrientation.HORIZONTAL : PlotOrientation.VERTICAL), false, false, false);
    CategoryPlot plot = (CategoryPlot) this.chart.getPlot();
    CategoryAxis categoryAxis = plot.getDomainAxis();
    categoryAxis.setLabelFont(new Font("", Font.TRUETYPE_FONT, 9));
    categoryAxis.setTickLabelFont(new Font("", Font.TRUETYPE_FONT, 9));
    NumberAxis numberAxis = (NumberAxis) plot.getRangeAxis();
    numberAxis.setLabelFont(new Font("", Font.TRUETYPE_FONT, 9));
    this.setPlotColor(plot, names, colors);
    this.chart.setTitle(new TextTitle(title, new Font("", Font.TRUETYPE_FONT, 9)));
}
Also used : TextTitle(org.jfree.chart.title.TextTitle) NumberAxis(org.jfree.chart.axis.NumberAxis) CategoryAxis(org.jfree.chart.axis.CategoryAxis) DefaultCategoryDataset(org.jfree.data.category.DefaultCategoryDataset) Paint(java.awt.Paint) CategoryPlot(org.jfree.chart.plot.CategoryPlot) Font(java.awt.Font)

Aggregations

CategoryPlot (org.jfree.chart.plot.CategoryPlot)22 JFreeChart (org.jfree.chart.JFreeChart)16 CategoryAxis (org.jfree.chart.axis.CategoryAxis)15 NumberAxis (org.jfree.chart.axis.NumberAxis)11 RectangleInsets (org.jfree.ui.RectangleInsets)9 BarRenderer (org.jfree.chart.renderer.category.BarRenderer)8 StandardBarPainter (org.jfree.chart.renderer.category.StandardBarPainter)7 DefaultCategoryDataset (org.jfree.data.category.DefaultCategoryDataset)7 Paint (java.awt.Paint)6 Color (java.awt.Color)5 ShiftedCategoryAxis (hudson.util.ShiftedCategoryAxis)3 ArrayList (java.util.ArrayList)3 StackedAreaRenderer (org.jfree.chart.renderer.category.StackedAreaRenderer)3 StackedAreaRenderer2 (hudson.util.StackedAreaRenderer2)2 BasicStroke (java.awt.BasicStroke)2 Font (java.awt.Font)2 ColorScheme (org.baderlab.csplugins.enrichmentmap.style.ColorScheme)2 LogarithmicAxis (org.jfree.chart.axis.LogarithmicAxis)2 ValueAxis (org.jfree.chart.axis.ValueAxis)2 ItemLabelPosition (org.jfree.chart.labels.ItemLabelPosition)2