Search in sources :

Example 71 with CategoryDataset

use of org.jfree.data.category.CategoryDataset in project Gemma by PavlidisLab.

the class ExpressionExperimentQCController method writePCAScree.

private boolean writePCAScree(OutputStream os, SVDValueObject svdo) throws Exception {
    /*
         * Make a scree plot.
         */
    CategoryDataset series = this.getPCAScree(svdo);
    if (series.getColumnCount() == 0) {
        return false;
    }
    int MAX_COMPONENTS_FOR_SCREE = 10;
    ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme());
    JFreeChart chart = ChartFactory.createBarChart("", "Component (up to" + MAX_COMPONENTS_FOR_SCREE + ")", "Fraction of var.", series, PlotOrientation.VERTICAL, false, false, false);
    BarRenderer renderer = (BarRenderer) chart.getCategoryPlot().getRenderer();
    renderer.setBasePaint(Color.white);
    renderer.setShadowVisible(false);
    chart.getCategoryPlot().setRangeGridlinesVisible(false);
    chart.getCategoryPlot().setDomainGridlinesVisible(false);
    ChartUtilities.writeChartAsPNG(os, chart, ExpressionExperimentQCController.DEFAULT_QC_IMAGE_SIZE_PX, ExpressionExperimentQCController.DEFAULT_QC_IMAGE_SIZE_PX);
    return true;
}
Also used : DefaultCategoryDataset(org.jfree.data.category.DefaultCategoryDataset) CategoryDataset(org.jfree.data.category.CategoryDataset) DefaultMultiValueCategoryDataset(org.jfree.data.statistics.DefaultMultiValueCategoryDataset) BarRenderer(org.jfree.chart.renderer.category.BarRenderer) JFreeChart(org.jfree.chart.JFreeChart)

Example 72 with CategoryDataset

use of org.jfree.data.category.CategoryDataset in project xwiki-platform by xwiki.

the class AbstractCategoryPlotGenerator method generate.

@Override
public Plot generate(ChartModel model, Map<String, String> parameters) throws PlotGeneratorException {
    CategoryDataset dataset;
    CategoryAxis domainAxis;
    ValueAxis rangeAxis;
    if (model.getDataset() instanceof CategoryDataset) {
        dataset = (CategoryDataset) model.getDataset();
    } else {
        throw new PlotGeneratorException("Incompatible dataset for category plot.");
    }
    if (model.getAxis(0) instanceof CategoryAxis) {
        domainAxis = (CategoryAxis) model.getAxis(0);
    } else {
        throw new PlotGeneratorException("Incompatible axis 0 for category plot.");
    }
    if (model.getAxis(1) instanceof ValueAxis) {
        rangeAxis = (ValueAxis) model.getAxis(1);
    } else {
        throw new PlotGeneratorException("Incompatible axis 1 for category plot.");
    }
    return new CategoryPlot(dataset, domainAxis, rangeAxis, getRenderer(parameters));
}
Also used : CategoryAxis(org.jfree.chart.axis.CategoryAxis) CategoryDataset(org.jfree.data.category.CategoryDataset) ValueAxis(org.jfree.chart.axis.ValueAxis) CategoryPlot(org.jfree.chart.plot.CategoryPlot) PlotGeneratorException(org.xwiki.chart.PlotGeneratorException)

Example 73 with CategoryDataset

use of org.jfree.data.category.CategoryDataset in project tdq-studio-se by Talend.

the class HideSeriesChartDialog method createUtilityControl.

private Composite createUtilityControl(Composite parent) {
    Composite comp = new Composite(parent, SWT.BORDER);
    comp.setLayout(new RowLayout());
    comp.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_GRAY));
    if (isCountAvgNull) {
        XYDataset dataset = chart.getXYPlot().getDataset();
        int count = dataset.getSeriesCount();
        for (int i = 0; i < count; i++) {
            Button checkBtn = new Button(comp, SWT.CHECK);
            checkBtn.setText(dataset.getSeriesKey(i).toString());
            checkBtn.setSelection(true);
            checkBtn.addSelectionListener(listener);
            checkBtn.setData(SERIES_KEY_ID, i);
        }
    }
    if (isMinMaxDate) {
        CategoryPlot plot = (CategoryPlot) chart.getPlot();
        CategoryDataset dataset = plot.getDataset();
        int count = dataset.getRowCount();
        for (int i = 0; i < count; i++) {
            Button checkBtn = new Button(comp, SWT.CHECK);
            checkBtn.setText(dataset.getRowKey(i).toString());
            checkBtn.setSelection(true);
            checkBtn.addSelectionListener(listener);
            checkBtn.setData(SERIES_KEY_ID, i);
        }
    }
    return comp;
}
Also used : Composite(org.eclipse.swt.widgets.Composite) Button(org.eclipse.swt.widgets.Button) RowLayout(org.eclipse.swt.layout.RowLayout) CategoryDataset(org.jfree.data.category.CategoryDataset) XYDataset(org.jfree.data.xy.XYDataset) CategoryPlot(org.jfree.chart.plot.CategoryPlot)

Example 74 with CategoryDataset

use of org.jfree.data.category.CategoryDataset in project tdq-studio-se by Talend.

the class ChartDecorator method decorateBenfordLawChartByKCD.

/**
 * Decorate the benford law chart. in this method the line chart will be overlay on top of bar chart.
 *
 * @param dataset
 * @param barChart
 * @param title
 * @param categoryAxisLabel
 * @param dotChartLabels
 * @param formalValues
 * @return JFreeChart
 */
@SuppressWarnings("deprecation")
public static JFreeChart decorateBenfordLawChartByKCD(CategoryDataset dataset, Object customerDataset, JFreeChart barChart, String title, String categoryAxisLabel, List<String> dotChartLabels, double[] formalValues) {
    CategoryPlot barplot = barChart.getCategoryPlot();
    decorateBarChart(barChart, new BenfordLawLineAndShapeRenderer());
    // display percentage on top of the bar
    DecimalFormat df = new DecimalFormat(PERCENT_FORMAT);
    // $NON-NLS-1$
    barplot.getRenderer().setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator("{2}", df));
    barplot.getRenderer().setBasePositiveItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BASELINE_CENTER));
    // set the display of Y axis
    NumberAxis numAxis = (NumberAxis) barplot.getRangeAxis();
    numAxis.setNumberFormatOverride(df);
    CategoryDataset lineDataset = getLineDataset(dotChartLabels, formalValues);
    JFreeChart lineChart = ChartFactory.createLineChart(null, title, categoryAxisLabel, lineDataset, PlotOrientation.VERTICAL, false, false, false);
    CategoryPlot plot = lineChart.getCategoryPlot();
    if (customerDataset != null) {
        barplot.setDataset(2, new EncapsulationCumstomerDataset(dataset, customerDataset));
    }
    // show the value on the right axis of the chart(keep the comment)
    // NumberAxis numberaxis = new NumberAxis(DefaultMessagesImpl.getString("TopChartFactory.Value"));
    // plot.setRangeAxis(10, numberaxis);
    NumberAxis vn = (NumberAxis) plot.getRangeAxis();
    vn.setNumberFormatOverride(df);
    // set points format
    LineAndShapeRenderer renderer = (LineAndShapeRenderer) plot.getRenderer();
    renderer.setPaint(COLOR_LIST.get(1));
    renderer.setSeriesShape(1, new Rectangle2D.Double(-1.5, -1.5, 3, 3));
    // show the point shape
    renderer.setShapesVisible(true);
    // do not show the line
    renderer.setBaseLinesVisible(false);
    // add the bar chart into the line chart
    CategoryItemRenderer barChartRender = barplot.getRenderer();
    barplot.setDataset(0, lineDataset);
    barplot.setRenderer(0, plot.getRenderer());
    barplot.setDataset(1, dataset);
    barplot.setRenderer(1, barChartRender);
    return barChart;
}
Also used : LineAndShapeRenderer(org.jfree.chart.renderer.category.LineAndShapeRenderer) StandardCategoryItemLabelGenerator(org.jfree.chart.labels.StandardCategoryItemLabelGenerator) NumberAxis(org.jfree.chart.axis.NumberAxis) CategoryItemRenderer(org.jfree.chart.renderer.category.CategoryItemRenderer) DecimalFormat(java.text.DecimalFormat) Rectangle2D(java.awt.geom.Rectangle2D) CategoryPlot(org.jfree.chart.plot.CategoryPlot) JFreeChart(org.jfree.chart.JFreeChart) DefaultCategoryDataset(org.jfree.data.category.DefaultCategoryDataset) CategoryDataset(org.jfree.data.category.CategoryDataset) EncapsulationCumstomerDataset(org.talend.dataprofiler.chart.util.EncapsulationCumstomerDataset) ItemLabelPosition(org.jfree.chart.labels.ItemLabelPosition)

Example 75 with CategoryDataset

use of org.jfree.data.category.CategoryDataset in project tdq-studio-se by Talend.

the class TOPChartService method getSeriesRowCount.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.dataprofiler.service.ITOPChartService#getSeriesRowCount(java.lang.Object)
     */
@Override
public int getSeriesRowCount(Object chart) {
    CategoryPlot plot = (CategoryPlot) ((JFreeChart) chart).getPlot();
    CategoryDataset dataset = plot.getDataset();
    return dataset.getRowCount();
}
Also used : DefaultBoxAndWhiskerCategoryDataset(org.jfree.data.statistics.DefaultBoxAndWhiskerCategoryDataset) DefaultCategoryDataset(org.jfree.data.category.DefaultCategoryDataset) BoxAndWhiskerCategoryDataset(org.jfree.data.statistics.BoxAndWhiskerCategoryDataset) CategoryDataset(org.jfree.data.category.CategoryDataset) CategoryPlot(org.jfree.chart.plot.CategoryPlot)

Aggregations

CategoryDataset (org.jfree.data.category.CategoryDataset)107 DefaultCategoryDataset (org.jfree.data.category.DefaultCategoryDataset)41 CategoryAxis (org.jfree.chart.axis.CategoryAxis)35 CategoryPlot (org.jfree.chart.plot.CategoryPlot)29 Test (org.junit.Test)29 Paint (java.awt.Paint)28 NumberAxis (org.jfree.chart.axis.NumberAxis)21 CategoryItemRenderer (org.jfree.chart.renderer.category.CategoryItemRenderer)20 JFreeChart (org.jfree.chart.JFreeChart)17 ValueAxis (org.jfree.chart.axis.ValueAxis)17 BarRenderer (org.jfree.chart.renderer.category.BarRenderer)16 Range (org.jfree.data.Range)13 PlotOrientation (org.jfree.chart.plot.PlotOrientation)11 DefaultCategoryItemRenderer (org.jfree.chart.renderer.category.DefaultCategoryItemRenderer)11 LineAndShapeRenderer (org.jfree.chart.renderer.category.LineAndShapeRenderer)9 DefaultMultiValueCategoryDataset (org.jfree.data.statistics.DefaultMultiValueCategoryDataset)9 MultiValueCategoryDataset (org.jfree.data.statistics.MultiValueCategoryDataset)9 LegendItem (org.jfree.chart.LegendItem)8 DefaultIntervalCategoryDataset (org.jfree.data.category.DefaultIntervalCategoryDataset)8 DefaultStatisticalCategoryDataset (org.jfree.data.statistics.DefaultStatisticalCategoryDataset)8