[Bug 63153] New: Removing a data series from a scatter chart corrupts the workbook

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

[Bug 63153] New: Removing a data series from a scatter chart corrupts the workbook

Bugzilla from bugzilla@apache.org
https://bz.apache.org/bugzilla/show_bug.cgi?id=63153

            Bug ID: 63153
           Summary: Removing a data series from a scatter chart corrupts
                    the workbook
           Product: POI
           Version: 4.0.x-dev
          Hardware: PC
            Status: NEW
          Severity: normal
          Priority: P2
         Component: XDDF
          Assignee: [hidden email]
          Reporter: [hidden email]
  Target Milestone: ---

If a series is removed from a scatter chart, the workbook is corrupted.  When
Excel 2011 for Mac or Excel 2010 opens the workbook, Excel reports that the
workbook is damaged.  I am using POI version 4.0.1

This has been seen both in charts added to a workbook, and charts that are
already in existing workbooks.

The code below adds a sheet to a workbook, adds a scatter chart to the sheet,
and adds two data series to the chart.  If nMaxSeries is set to 2 or more, the
series are not removed from the chart, and the workbook is not corrupted.  If
nMaxSeries is set to less than 2, at least one series is removed from the chart
and the workbook is corrupted.

        /**
         * This method creates a scatter chart in workbook, and adds two data
         * series. If either scatter series is removed, the chart is damaged.
         *
         * @param dstWorkbook
         */
        private static void removeChartSeriesTest(XSSFWorkbook dstWorkbook) {
                final String procName = "removeChartSeriesTest";
                final int nMaxSeries = 1;
                final XSSFSheet sheet = dstWorkbook.createSheet("Remove series
test");
                final XSSFDrawing xssfDrawing = sheet.createDrawingPatriarch();
                final XSSFClientAnchor anchor = xssfDrawing.createAnchor(0, 0,
0, 0, 1, 5, 20, 20);
                final XDDFChart chart = xssfDrawing.createChart(anchor);
                final XDDFValueAxis bottomAxis =
chart.createValueAxis(AxisPosition.BOTTOM);
                final XDDFValueAxis leftAxis =
chart.createValueAxis(AxisPosition.LEFT);

                // Initialize data data sources

                final Double dX[] = new Double[5];
                final Double dY1[] = new Double[5];
                final Double dY2[] = new Double[5];

                for (int n = 0; n < 5; ++n) {
                        dX[n] = (double) n;
                        dY1[n] = 2.0 * n;
                        dY2[n] = (double) (n * n);

                }

                final XDDFNumericalDataSource<Double> xData =
XDDFDataSourcesFactory.fromArray(dX, null);
                final XDDFNumericalDataSource<Double> yData1 =
XDDFDataSourcesFactory.fromArray(dY1, null);
                final XDDFNumericalDataSource<Double> yData2 =
XDDFDataSourcesFactory.fromArray(dY2, null);

                // Creat the chartdata

                final XDDFScatterChartData chartData = (XDDFScatterChartData)
chart.createData(ChartTypes.SCATTER, bottomAxis,
                                leftAxis);

                // Add the series

                chartData.addSeries(xData, yData1);
                chartData.addSeries(xData, yData2);

                System.out.println(String.format("\r\n%s:
chartData.getSeries.size=%d nMaxSheets=%d", procName,
                                chartData.getSeries().size(), nMaxSeries));

                // Remove any extra series

                while (chartData.getSeries().size() > nMaxSeries) {
                        chartData.getSeries().remove(0);
                }
                System.out.println(String.format("%s:
chartData.getSeries.size=%d", procName, chartData.getSeries().size()));

                // Finish up
                chart.plot(chartData);
                final int nSheet = dstWorkbook.getSheetIndex(sheet);
                dstWorkbook.setSelectedTab(nSheet);
                dstWorkbook.setActiveSheet(nSheet);
                dstWorkbook.setFirstVisibleTab(nSheet);

        }

--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

[Bug 63153] Removing a data series from a scatter chart corrupts the workbook

Bugzilla from bugzilla@apache.org
https://bz.apache.org/bugzilla/show_bug.cgi?id=63153

Dominik Stadler <[hidden email]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 OS|                            |All

--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

[Bug 63153] Removing a data series from a scatter chart corrupts the workbook

Bugzilla from bugzilla@apache.org
In reply to this post by Bugzilla from bugzilla@apache.org
https://bz.apache.org/bugzilla/show_bug.cgi?id=63153

--- Comment #1 from David Gauntt <[hidden email]> ---
Created attachment 36579
  --> https://bz.apache.org/bugzilla/attachment.cgi?id=36579&action=edit
Patch to XDDFChartData to fix 63153

This code should replace the method getSeries() in XDDFChartData.  The patch
includes the method _removeSeries(int), which should be made abstract and
implemented in all classes that extend XDDFChartData.  I will add a patch to
XDDFScatterChartData  and a JUnit test case shortly.

--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

[Bug 63153] Removing a data series from a scatter chart corrupts the workbook

Bugzilla from bugzilla@apache.org
In reply to this post by Bugzilla from bugzilla@apache.org
https://bz.apache.org/bugzilla/show_bug.cgi?id=63153

--- Comment #2 from David Gauntt <[hidden email]> ---
Created attachment 36580
  --> https://bz.apache.org/bugzilla/attachment.cgi?id=36580&action=edit
Additional patch to fix bug 63153

This patch should be added to the following classes, which is the list of
classes that extend XDDFChartData

XDDFBarChartData
XDDFLineChartData
XDDFPieChartData
XDDFRadarChartData
XDDFScatterChartData

After the patch has been added to all of these classes, then _removeSeries in
XDDFChartData should be made abstract.

A test case for XDDFScatterChartData will be posted shortly.

--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

[Bug 63153] Removing a data series from a scatter chart corrupts the workbook

Bugzilla from bugzilla@apache.org
In reply to this post by Bugzilla from bugzilla@apache.org
https://bz.apache.org/bugzilla/show_bug.cgi?id=63153

--- Comment #3 from David Gauntt <[hidden email]> ---
Created attachment 36581
  --> https://bz.apache.org/bugzilla/attachment.cgi?id=36581&action=edit
JUnit test case to verify bug fix for 63153

This test case writes 5 workbooks to the folder custom-reports-test.  Each
workbook contains a single sheet with a single scatter chart.

testDontRemoveSeries.xlsx: the scatter chart has two data series. Excel 2010
opens and displays it without trouble.

testRemoveSeries0.xlsx: the first data series has been removed by calling
getSeries().remove(0).  The workbook is corrupted, and Excel 2010 fixes it by
deleting the chart.

testBugFixRemoveSeries0.xlsx: the first data series has been removed by calling
removeSeries(0).   Excel 2010 opens and displays it without trouble.  However,
the appearance of the remaining data series is different than in
testDontRemoveSeries.xlsx.  I will open a new bug report to deal with this.

testRemoveSeries1.xlsx, testBugFixRemoveSeries1.xlsx: the same as the two
preceding workbooks, but with the second series removed instead of the first.

--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

[Bug 63153] Removing a data series from a scatter chart corrupts the workbook

Bugzilla from bugzilla@apache.org
In reply to this post by Bugzilla from bugzilla@apache.org
https://bz.apache.org/bugzilla/show_bug.cgi?id=63153

David Gauntt <[hidden email]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  Attachment #36581|0                           |1
        is obsolete|                            |

--- Comment #4 from David Gauntt <[hidden email]> ---
Created attachment 36582
  --> https://bz.apache.org/bugzilla/attachment.cgi?id=36582&action=edit
Revised JUnit test case to verify bug fix for 63153

This test case writes 5 workbooks to the folder custom-reports-test.  Each
workbook contains a single sheet with a single scatter chart

testDontRemoveSeries.xlsx: this tests adds two data series and removes none.
Excel 2010 opens and displays it without trouble.

testRemoveSeries0.xlsx, testRemoveLastSeries.xlsx: These tests add three data
series and removes the either the first or the last series by calling
getSeries().remove(n).  The workbook is corrupted, and Excel 2010 fixes it by
deleting the chart.

testBugFixRemoveSeries0.xlsx, testBugFixRemoveLastSeries.xlsx:  These tests add
three data series and removes the either the first or the last series by
calling removeSeries(n).  Excel opens and displays the workbook without
trouble.  The appearance of the charts is similar to the chart in
testDontRemoveSeries.

--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

[Bug 63153] Removing a data series from a scatter chart corrupts the workbook

Bugzilla from bugzilla@apache.org
In reply to this post by Bugzilla from bugzilla@apache.org
https://bz.apache.org/bugzilla/show_bug.cgi?id=63153

Alain Fagot Bearez <[hidden email]> changed:

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

--- Comment #5 from Alain Fagot Bearez <[hidden email]> ---
fix by r1859590

--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]