Search in sources :

Example 1 with LegendProperties

use of org.krysalis.jcharts.properties.LegendProperties in project activityinfo by bedatadriven.

the class ChartRendererJC method computeLegendProperties.

protected LegendProperties computeLegendProperties(PivotChartReportElement element, int dpi, List<PivotTableData.Axis> series) {
    // if there is only series, there is no need for a legend
    if (series.size() <= 1) {
        return null;
    }
    ChartFont font = new ChartFont(new Font(SANS_SERIF, Font.PLAIN, fontSize(10, dpi)), Color.BLACK);
    LegendProperties p = new LegendProperties();
    p.setChartFont(font);
    p.setBorderStroke(null);
    p.setIconBorderPaint(null);
    if (element.getType() == Type.Pie) {
        p.setPlacement(LegendProperties.RIGHT);
    } else {
        p.setPlacement(maxLegendTextLength(series) > 30 ? LegendProperties.BOTTOM : LegendProperties.RIGHT);
    }
    p.setNumColumns(1);
    return p;
}
Also used : ChartFont(org.krysalis.jcharts.properties.util.ChartFont) LegendProperties(org.krysalis.jcharts.properties.LegendProperties) ChartFont(org.krysalis.jcharts.properties.util.ChartFont) Font(com.google.code.appengine.awt.Font)

Example 2 with LegendProperties

use of org.krysalis.jcharts.properties.LegendProperties in project activityinfo by bedatadriven.

the class ChartRendererJC method createPieChart.

/**
 * Creates a JChart PieChart from our report element
 */
protected Chart createPieChart(PivotChartReportElement element, boolean includeTitle, int width, int height, int dpi) throws IOException, ChartDataException {
    PivotTableData table = element.getContent().getData();
    List<PivotTableData.Axis> categories = table.getRootCategory().getLeaves();
    PivotTableData.Axis series = table.getRootSeries().getLeaves().get(0);
    PieChart2DProperties pieProps = new PieChart2DProperties();
    pieProps.setValueLabelFont(new ChartFont(new Font(SANS_SERIF, Font.PLAIN, fontSize(10, dpi)), Color.black));
    pieProps.setShowGrouping(true);
    pieProps.setPieLabelType(PieLabelType.VALUE_LABELS);
    pieProps.setBorderChartStroke(ChartStroke.DEFAULT_ZERO_LINE);
    PieChartDataSet dataSet = new PieChartDataSet(includeTitle ? element.getTitle() : null, toDataArray(categories, series), toLabelArray(element.getContent(), categories), computePaints(categories), pieProps);
    LegendProperties legendProps = computeLegendProperties(element, dpi, categories);
    ChartProperties chartProps = computeChartProperties(dpi);
    return new PieChart2D(dataSet, legendProps, chartProps, width, height);
}
Also used : ChartFont(org.krysalis.jcharts.properties.util.ChartFont) PieChartDataSet(org.krysalis.jcharts.chartData.PieChartDataSet) PivotTableData(org.activityinfo.shared.report.content.PivotTableData) PieChart2D(org.krysalis.jcharts.nonAxisChart.PieChart2D) PieChart2DProperties(org.krysalis.jcharts.properties.PieChart2DProperties) LegendProperties(org.krysalis.jcharts.properties.LegendProperties) ChartProperties(org.krysalis.jcharts.properties.ChartProperties) LineChartProperties(org.krysalis.jcharts.properties.LineChartProperties) ClusteredBarChartProperties(org.krysalis.jcharts.properties.ClusteredBarChartProperties) BarChartProperties(org.krysalis.jcharts.properties.BarChartProperties) StackedBarChartProperties(org.krysalis.jcharts.properties.StackedBarChartProperties) ChartFont(org.krysalis.jcharts.properties.util.ChartFont) Font(com.google.code.appengine.awt.Font)

Aggregations

Font (com.google.code.appengine.awt.Font)2 LegendProperties (org.krysalis.jcharts.properties.LegendProperties)2 ChartFont (org.krysalis.jcharts.properties.util.ChartFont)2 PivotTableData (org.activityinfo.shared.report.content.PivotTableData)1 PieChartDataSet (org.krysalis.jcharts.chartData.PieChartDataSet)1 PieChart2D (org.krysalis.jcharts.nonAxisChart.PieChart2D)1 BarChartProperties (org.krysalis.jcharts.properties.BarChartProperties)1 ChartProperties (org.krysalis.jcharts.properties.ChartProperties)1 ClusteredBarChartProperties (org.krysalis.jcharts.properties.ClusteredBarChartProperties)1 LineChartProperties (org.krysalis.jcharts.properties.LineChartProperties)1 PieChart2DProperties (org.krysalis.jcharts.properties.PieChart2DProperties)1 StackedBarChartProperties (org.krysalis.jcharts.properties.StackedBarChartProperties)1