https://bz.apache.org/bugzilla/show_bug.cgi?id=67638
Bug ID: 67638
Summary: Unable to open .docx file when adding XWPFChart and
XDDFChart
Product: POI
Version: unspecified
Hardware: Other
Status: NEW
Severity: major
Priority: P2
Component: XDDF
Assignee: [email protected]
Reporter: [email protected]
Target Milestone: ---
I have been using the same line of code for a few months now to generate a word
document that includes XWPF and XDDF charts and suddenly it does not work. Here
is an exaple that I tried that was on stackFlow that appeared to work for many
people except for me:
private static void setBarData(XWPFChart chart, String chartTitle, String[]
series, String[] categories, Double[] values1, Double[] values2) {
// Use a category axis for the bottom axis.
XDDFChartAxis bottomAxis =
chart.createCategoryAxis(AxisPosition.BOTTOM);
bottomAxis.setTitle(chartTitle);
XDDFValueAxis leftAxis = chart.createValueAxis(AxisPosition.LEFT);
leftAxis.setTitle(",");
leftAxis.setCrosses(AxisCrosses.AUTO_ZERO);
leftAxis.setMajorTickMark(AxisTickMark.OUT);
leftAxis.setCrossBetween(AxisCrossBetween.BETWEEN);
final int numOfPoints = categories.length;
final String categoryDataRange = chart.formatRange(new
CellRangeAddress(1, numOfPoints, COLUMN_LANGUAGES, COLUMN_LANGUAGES));
final String valuesDataRange = chart.formatRange(new
CellRangeAddress(1, numOfPoints, COLUMN_COUNTRIES, COLUMN_COUNTRIES));
final XDDFDataSource<?> categoriesData =
XDDFDataSourcesFactory.fromArray(categories, categoryDataRange,
COLUMN_LANGUAGES);
final XDDFNumericalDataSource<? extends Number> valuesData =
XDDFDataSourcesFactory.fromArray(values1, valuesDataRange, COLUMN_COUNTRIES);
valuesData.setFormatCode("General");
values1[6] = 16.0; // if you ever want to change the underlying data,
it has to be done before building the data source
XDDFBarChartData bar = (XDDFBarChartData)
chart.createData(ChartTypes.BAR, bottomAxis, leftAxis);
XDDFBarChartData.Series series1 = (XDDFBarChartData.Series)
bar.addSeries(categoriesData, valuesData);
series1.setTitle(chartTitle);
bar.setVaryColors(true);
bar.setBarDirection(BarDirection.COL);
chart.plot(bar);
XDDFChartLegend legend = chart.getOrAddLegend();
legend.setPosition(LegendPosition.LEFT);
legend.setOverlay(false);
chart.setTitleText(chartTitle);
chart.setTitleOverlay(false);
chart.setAutoTitleDeleted(false);
}
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]