use of org.apache.poi.ss.usermodel.charts.ChartAxis in project ocvn by devgateway.
the class ExcelChartDefault method createWorkbook.
@Override
public Workbook createWorkbook() {
final ExcelChartSheet excelChartSheet = new ExcelChartSheetDefault(workbook, type.toString());
final Chart chart = excelChartSheet.createChartAndLegend();
addCategories(excelChartSheet);
addValues(excelChartSheet);
final CustomChartDataFactory customChartDataFactory = new CustomChartDataFactoryDefault();
final CustomChartData chartData = customChartDataFactory.createChartData(type, title);
final ChartDataSource<?> categoryDataSource = excelChartSheet.getCategoryChartDataSource();
final List<ChartDataSource<Number>> valuesDataSource = excelChartSheet.getValuesChartDataSource();
for (int i = 0; i < valuesDataSource.size(); i++) {
final ChartDataSource<Number> valueDataSource = valuesDataSource.get(i);
if (seriesTitle.isEmpty()) {
chartData.addSeries(categoryDataSource, valueDataSource);
} else {
chartData.addSeries(seriesTitle.get(i), categoryDataSource, valueDataSource);
}
}
// we don't have any axis for a pie chart
if (type.equals(ChartType.pie)) {
chart.plot(chartData);
} else {
// Use a category axis for the bottom axis.
final ChartAxis bottomAxis = chart.getChartAxisFactory().createCategoryAxis(AxisPosition.BOTTOM);
final ValueAxis leftAxis = chart.getChartAxisFactory().createValueAxis(AxisPosition.LEFT);
leftAxis.setCrosses(AxisCrosses.AUTO_ZERO);
chart.plot(chartData, bottomAxis, leftAxis);
}
return workbook;
}
use of org.apache.poi.ss.usermodel.charts.ChartAxis in project ocvn by devgateway.
the class XSSFBarChartData method fillChart.
@Override
public void fillChart(final Chart chart, final ChartAxis... axis) {
if (!(chart instanceof XSSFChart)) {
throw new IllegalArgumentException("Chart must be instance of XSSFChart");
}
final XSSFChart xssfChart = (XSSFChart) chart;
final CTPlotArea plotArea = xssfChart.getCTChart().getPlotArea();
final CTBarChart barChart = plotArea.addNewBarChart();
barChart.addNewVaryColors().setVal(false);
// set bars orientation
barChart.addNewBarDir().setVal(barDir);
xssfChart.setTitle(this.title);
CTValAx[] ctValAx = plotArea.getValAxArray();
if (ctValAx.length != 0) {
ctValAx[0].addNewMajorGridlines().addNewSpPr().addNewSolidFill();
ctValAx[0].getCrossBetween().setVal(STCrossBetween.BETWEEN);
}
for (CustomChartSeries s : series) {
s.addToChart(barChart);
}
for (ChartAxis ax : axis) {
barChart.addNewAxId().setVal(ax.getId());
}
}
use of org.apache.poi.ss.usermodel.charts.ChartAxis in project ocvn by devgateway.
the class XSSFBubbleChartData method fillChart.
@Override
public void fillChart(final Chart chart, final ChartAxis... axis) {
if (!(chart instanceof XSSFChart)) {
throw new IllegalArgumentException("Chart must be instance of XSSFChart");
}
final XSSFChart xssfChart = (XSSFChart) chart;
final CTPlotArea plotArea = xssfChart.getCTChart().getPlotArea();
final CTBubbleChart bubbleChart = plotArea.addNewBubbleChart();
for (CustomChartSeries s : series) {
s.addToChart(bubbleChart);
}
for (ChartAxis ax : axis) {
bubbleChart.addNewAxId().setVal(ax.getId());
}
xssfChart.setTitle(this.title);
}
use of org.apache.poi.ss.usermodel.charts.ChartAxis in project oc-explorer by devgateway.
the class ExcelChartDefault method createWorkbook.
@Override
public Workbook createWorkbook() {
final ExcelChartSheet excelChartSheet = new ExcelChartSheetDefault(workbook, type.toString());
final Chart chart = excelChartSheet.createChartAndLegend();
addCategories(excelChartSheet);
addValues(excelChartSheet);
final CustomChartDataFactory customChartDataFactory = new CustomChartDataFactoryDefault();
final CustomChartData chartData = customChartDataFactory.createChartData(type, title);
final ChartDataSource<?> categoryDataSource = excelChartSheet.getCategoryChartDataSource();
final List<ChartDataSource<Number>> valuesDataSource = excelChartSheet.getValuesChartDataSource();
for (int i = 0; i < valuesDataSource.size(); i++) {
final ChartDataSource<Number> valueDataSource = valuesDataSource.get(i);
if (seriesTitle.isEmpty()) {
chartData.addSeries(categoryDataSource, valueDataSource);
} else {
chartData.addSeries(seriesTitle.get(i), categoryDataSource, valueDataSource);
}
}
// we don't have any axis for a pie chart
if (type.equals(ChartType.pie)) {
chart.plot(chartData);
} else {
// Use a category axis for the bottom axis.
final ChartAxis bottomAxis = chart.getChartAxisFactory().createCategoryAxis(AxisPosition.BOTTOM);
final ValueAxis leftAxis = chart.getChartAxisFactory().createValueAxis(AxisPosition.LEFT);
leftAxis.setCrosses(AxisCrosses.AUTO_ZERO);
chart.plot(chartData, bottomAxis, leftAxis);
}
return workbook;
}
use of org.apache.poi.ss.usermodel.charts.ChartAxis in project oc-explorer by devgateway.
the class XSSFAreaChartData method fillChart.
@Override
public void fillChart(final Chart chart, final ChartAxis... axis) {
if (!(chart instanceof XSSFChart)) {
throw new IllegalArgumentException("Chart must be instance of XSSFChart");
}
final XSSFChart xssfChart = (XSSFChart) chart;
final CTPlotArea plotArea = xssfChart.getCTChart().getPlotArea();
final CTAreaChart areChart = plotArea.addNewAreaChart();
areChart.addNewVaryColors().setVal(false);
xssfChart.setTitleText(this.title);
CTValAx[] ctValAx = plotArea.getValAxArray();
if (ctValAx.length != 0) {
ctValAx[0].addNewMajorGridlines().addNewSpPr().addNewSolidFill();
ctValAx[0].getCrossBetween().setVal(STCrossBetween.BETWEEN);
}
for (CustomChartSeries s : series) {
s.addToChart(areChart);
}
for (ChartAxis ax : axis) {
areChart.addNewAxId().setVal(ax.getId());
}
}
Aggregations