You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by bu...@apache.org on 2020/12/20 22:03:58 UTC

[Bug 65016] New: Creating a chart throws IndexOutOfBoundsException

https://bz.apache.org/bugzilla/show_bug.cgi?id=65016

            Bug ID: 65016
           Summary: Creating a chart throws IndexOutOfBoundsException
           Product: POI
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: major
          Priority: P2
         Component: XDDF
          Assignee: dev@poi.apache.org
          Reporter: dominik.stadler@gmx.at
  Target Milestone: ---

Created attachment 37636
  --> https://bz.apache.org/bugzilla/attachment.cgi?id=37636&action=edit
List of dates and values for a chart

The following unit-test combined with the attached sample document throws an
exception.

I tried to "fix" it, but couldn't, if this is some incorrect usage of the new
XDDFChart functionality, we should at least try to validate the inputs and
provide a better error message.


java.lang.IndexOutOfBoundsException
        at org.apache.xmlbeans.impl.store.Xobj.removeElement(Xobj.java:2099)
        at org.apache.xmlbeans.impl.store.Xobj.remove_element(Xobj.java:2130)
        at
org.openxmlformats.schemas.drawingml.x2006.chart.impl.CTNumDataImpl.unsetPtCount(CTNumDataImpl.java:168)
        at
org.apache.poi.xddf.usermodel.chart.XDDFDataSource.fillNumericalCache(XDDFDataSource.java:84)
        at
org.apache.poi.xddf.usermodel.chart.XDDFChartData$Series.plot(XDDFChartData.java:214)
        at
org.apache.poi.xddf.usermodel.chart.XDDFChart.plot(XDDFChart.java:418)
        at
org.apache.poi.xddf.usermodel.chart.TestXDDFChart.testException(TestXDDFChart.java:102)



    @Test
    public void testException() throws IOException {
        try (XSSFWorkbook wb =
XSSFTestDataSamples.openSampleWorkbook("chart20201220.xlsx")) {
            XSSFSheet splitSheet = wb.getSheet("Splits");

            XDDFChart chart = newXDDFChart();
            XDDFChartLegend legend = chart.getOrAddLegend();
            legend.setPosition(LegendPosition.BOTTOM);

            // Use a category axis for the bottom axis.
            XDDFCategoryAxis bottomAxis =
chart.createCategoryAxis(AxisPosition.BOTTOM);
            XDDFValueAxis leftAxis = chart.createValueAxis(AxisPosition.LEFT);
            leftAxis.setCrosses(AxisCrosses.AUTO_ZERO);

            XDDFChartData data = chart.createData(ChartTypes.LINE, bottomAxis,
leftAxis);

            // starting row 1 to include description
            XDDFNumericalDataSource<Double> xs =
XDDFDataSourcesFactory.fromNumericCellRange(splitSheet,
                    new CellRangeAddress(2, 100, 0, 0));
            XDDFNumericalDataSource<Double> ys1 =
XDDFDataSourcesFactory.fromNumericCellRange(splitSheet,
                    new CellRangeAddress(2, 100, 1, 1));

            data.addSeries(xs, ys1);

            chart.plot(data);

            try (OutputStream out = new
FileOutputStream("/tmp/chart20201220.xlsx")) {
                wb.write(out);
            }
        }
    }

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 65016] Creating a chart throws IndexOutOfBoundsException

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=65016

Alain Fagot Bearez <Al...@cua.li> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |NEEDINFO

--- Comment #2 from Alain Fagot Bearez <Al...@cua.li> ---
Following pull request should fix the exception which was thrown when trying to
unset an underlying XML element which was not set.

https://github.com/apache/poi/pull/220

Could you check if this also fixes your use case?

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 65016] Creating a chart throws IndexOutOfBoundsException

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=65016

--- Comment #1 from Dominik Stadler <do...@gmx.at> ---
This is on the latest trunk, btw.

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 65016] Creating a chart throws IndexOutOfBoundsException

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=65016

Dominik Stadler <do...@gmx.at> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEEDINFO                    |NEW

--- Comment #3 from Dominik Stadler <do...@gmx.at> ---
This seems to fix the issue for me, Thanks!

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 65016] Creating a chart throws IndexOutOfBoundsException

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=65016

Alain Fagot Bearez <Al...@cua.li> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|NEW                         |RESOLVED

--- Comment #4 from Alain Fagot Bearez <Al...@cua.li> ---
fixed by r1885700

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org