Example usage for org.apache.poi.xssf.usermodel XSSFChart getCTChart

List of usage examples for org.apache.poi.xssf.usermodel XSSFChart getCTChart

Introduction

In this page you can find the example usage for org.apache.poi.xssf.usermodel XSSFChart getCTChart.

Prototype

@Internal
public CTChart getCTChart() 

Source Link

Document

Return the underlying CTChart bean, within the Chart Space

Usage

From source file:com.vaadin.addon.spreadsheet.charts.converter.xssfreader.XSSFChartReader.java

private String getTitle(XSSFChart chart, List<AbstractSeriesData> plotData) {
    String title = "";

    final CTChart ctChart = chart.getCTChart();

    if (ctChart.isSetTitle()) {
        title = "" + chart.getTitle();

        // default title
        if (title.isEmpty() && plotData.size() > 0 && plotData.get(0).name != null) {
            title = plotData.get(0).name.toUpperCase();
        }/*from w  ww. jav a 2  s. c  o  m*/
    }

    return title;
}

From source file:org.tiefaces.components.websheet.utility.ChartUtility.java

License:MIT License

/**
 * init chart data.//from ww  w  .  ja  va 2  s  . co  m
 * 
 * @param chartId
 *            chartId.
 * @param chart
 *            chart.
 * @param wb
 *            wb.
 * @return chartdata.
 */
public static ChartData initChartDataFromXSSFChart(final String chartId, final XSSFChart chart,
        final XSSFWorkbook wb) {

    ThemesTable themeTable = wb.getStylesSource().getTheme();

    ChartData chartData = new ChartData();
    XSSFRichTextString chartTitle = chart.getTitle();
    if (chartTitle != null) {
        chartData.setTitle(chartTitle.toString());
    }
    CTChart ctChart = chart.getCTChart();
    ChartType chartType = ChartUtility.getChartType(ctChart);
    if (chartType == null) {
        throw new IllegalChartException("Unknown chart type");
    }

    chartData.setBgColor(ColorUtility.getBgColor(ctChart.getPlotArea(), themeTable));

    chartData.setId(chartId);
    chartData.setType(chartType);

    List<CTCatAx> ctCatAxList = ctChart.getPlotArea().getCatAxList();
    if ((ctCatAxList != null) && (!ctCatAxList.isEmpty())) {
        chartData.setCatAx(new ChartAxis(ctCatAxList.get(0)));
    }
    List<CTValAx> ctValAxList = ctChart.getPlotArea().getValAxList();
    if ((ctValAxList != null) && (!ctValAxList.isEmpty())) {
        chartData.setValAx(new ChartAxis(ctValAxList.get(0)));
    }

    ChartObject ctObj = chartType.createChartObject();

    if (ctObj == null) {
        throw new IllegalChartException("Cannot create chart object.");
    }

    setUpChartData(chartData, ctChart, themeTable, ctObj);

    return chartData;
}