Search in sources :

Example 1 with TalendBarRenderer

use of org.talend.dataprofiler.chart.TalendBarRenderer in project tdq-studio-se by Talend.

the class TopChartFactory method createMatchRuleBarChart.

/**
 * DOC zshen Comment method "createMatchRuleBarChart".
 *
 * @param title
 * @param dataset
 * @return
 */
public static JFreeChart createMatchRuleBarChart(String categoryAxisLabel, String valueAxisLabel, CategoryDataset dataset) {
    ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme());
    JFreeChart localJFreeChart = ChartFactory.createBarChart(null, categoryAxisLabel, valueAxisLabel, dataset, PlotOrientation.VERTICAL, false, true, false);
    localJFreeChart.addSubtitle(new TextTitle(Messages.getString("DataChart.title", sumItemCount(dataset), // $NON-NLS-1$
    sumGroupCount(dataset))));
    CategoryPlot plot = (CategoryPlot) localJFreeChart.getPlot();
    // get real color list from ChartDecorator.COLOR_LIST dataset.getColumnKeys()
    List<Color> currentColorList = null;
    try {
        currentColorList = getCurrentColorList(dataset.getColumnKeys());
    } catch (NumberFormatException e) {
        log.warn(e, e);
        currentColorList = ChartDecorator.COLOR_LIST;
    }
    BarRenderer barRenderer = new TalendBarRenderer(true, currentColorList);
    barRenderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());
    barRenderer.setBaseItemLabelsVisible(true);
    // remove the shadow
    barRenderer.setShadowVisible(Boolean.FALSE);
    plot.setRenderer(barRenderer);
    CategoryAxis localCategoryAxis = plot.getDomainAxis();
    localCategoryAxis.setCategoryMargin(0.25D);
    localCategoryAxis.setUpperMargin(0.02D);
    localCategoryAxis.setLowerMargin(0.02D);
    NumberAxis localNumberAxis = (NumberAxis) plot.getRangeAxis();
    localNumberAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    localNumberAxis.setUpperMargin(0.1D);
    return localJFreeChart;
}
Also used : TextTitle(org.jfree.chart.title.TextTitle) StandardCategoryItemLabelGenerator(org.jfree.chart.labels.StandardCategoryItemLabelGenerator) NumberAxis(org.jfree.chart.axis.NumberAxis) CategoryAxis(org.jfree.chart.axis.CategoryAxis) Color(java.awt.Color) BarRenderer(org.jfree.chart.renderer.category.BarRenderer) StackedBarRenderer(org.jfree.chart.renderer.category.StackedBarRenderer) XYBarRenderer(org.jfree.chart.renderer.xy.XYBarRenderer) TalendBarRenderer(org.talend.dataprofiler.chart.TalendBarRenderer) TalendBarRenderer(org.talend.dataprofiler.chart.TalendBarRenderer) JFreeChart(org.jfree.chart.JFreeChart) CategoryPlot(org.jfree.chart.plot.CategoryPlot)

Example 2 with TalendBarRenderer

use of org.talend.dataprofiler.chart.TalendBarRenderer in project tdq-studio-se by Talend.

the class TopChartFactory method createBarChart.

/**
 * mzhao create bar chart with default bar render class.
 *
 * @param titile
 * @param dataset
 * @param showLegend
 * @return
 */
public static JFreeChart createBarChart(String titile, CategoryDataset dataset, boolean showLegend) {
    // MOD hcheng for 6965,Use 2D bar charts instead of 3D bar charts
    // ADD msjian TDQ-5112 2012-4-10: after upgrate to jfreechart-1.0.12.jar, change the default chart wallPaint
    ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme());
    // TDQ-5112~
    JFreeChart chart = ChartFactory.createBarChart(null, titile, // $NON-NLS-1$
    Messages.getString("TopChartFactory.count"), // $NON-NLS-1$
    dataset, // $NON-NLS-1$
    PlotOrientation.VERTICAL, // $NON-NLS-1$
    showLegend, true, false);
    ChartDecorator.decorateBarChart(chart, new TalendBarRenderer(true, ChartDecorator.COLOR_LIST));
    return chart;
}
Also used : TalendBarRenderer(org.talend.dataprofiler.chart.TalendBarRenderer) JFreeChart(org.jfree.chart.JFreeChart)

Example 3 with TalendBarRenderer

use of org.talend.dataprofiler.chart.TalendBarRenderer in project tdq-studio-se by Talend.

the class TopChartFactory method createBarChartByKCD.

/**
 * create bar chart.
 *
 * @param titile
 * @param dataset
 * @return
 */
public static JFreeChart createBarChartByKCD(String title, CategoryDataset dataset, Object cusmomerDataset) {
    // ADD msjian TDQ-5112 2012-4-10: after upgrate to jfreechart-1.0.12.jar, change the default chart wallPaint
    ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme());
    // TDQ-5112~
    JFreeChart createBarChart = ChartFactory.createBarChart(null, Messages.getString("TopChartFactory.Value"), title, dataset, PlotOrientation.HORIZONTAL, false, false, // $NON-NLS-1$
    false);
    CategoryPlot plot = createBarChart.getCategoryPlot();
    if (cusmomerDataset != null) {
        plot.setDataset(1, new EncapsulationCumstomerDataset(dataset, cusmomerDataset));
    }
    CategoryAxis domainAxis = plot.getDomainAxis();
    domainAxis.setTickLabelPaint(NULL_FIELD, Color.RED);
    domainAxis.setTickLabelPaint(NULL_FIELD2, Color.RED);
    domainAxis.setTickLabelPaint(EMPTY_FIELD, Color.RED);
    // ADD TDQ-5251 msjian 2012-7-31: do not display the shadow
    BarRenderer renderer = new TalendBarRenderer(false, ChartDecorator.COLOR_LIST);
    renderer.setShadowVisible(false);
    // TDQ-5251~
    plot.setRenderer(renderer);
    return createBarChart;
}
Also used : CategoryAxis(org.jfree.chart.axis.CategoryAxis) BarRenderer(org.jfree.chart.renderer.category.BarRenderer) StackedBarRenderer(org.jfree.chart.renderer.category.StackedBarRenderer) XYBarRenderer(org.jfree.chart.renderer.xy.XYBarRenderer) TalendBarRenderer(org.talend.dataprofiler.chart.TalendBarRenderer) TalendBarRenderer(org.talend.dataprofiler.chart.TalendBarRenderer) JFreeChart(org.jfree.chart.JFreeChart) CategoryPlot(org.jfree.chart.plot.CategoryPlot)

Aggregations

JFreeChart (org.jfree.chart.JFreeChart)3 TalendBarRenderer (org.talend.dataprofiler.chart.TalendBarRenderer)3 CategoryAxis (org.jfree.chart.axis.CategoryAxis)2 CategoryPlot (org.jfree.chart.plot.CategoryPlot)2 BarRenderer (org.jfree.chart.renderer.category.BarRenderer)2 StackedBarRenderer (org.jfree.chart.renderer.category.StackedBarRenderer)2 XYBarRenderer (org.jfree.chart.renderer.xy.XYBarRenderer)2 Color (java.awt.Color)1 NumberAxis (org.jfree.chart.axis.NumberAxis)1 StandardCategoryItemLabelGenerator (org.jfree.chart.labels.StandardCategoryItemLabelGenerator)1 TextTitle (org.jfree.chart.title.TextTitle)1