chart2/source/view/charttypes/VSeriesPlotter.cxx |   16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

New commits:
commit ec31df481568f6a654e5f6c1d597dc8b963b99e6
Author:     Kurt Nordback <kurt.nordb...@protonmail.com>
AuthorDate: Sat May 28 15:29:31 2022 -0600
Commit:     Mike Kaganski <mike.kagan...@collabora.com>
CommitDate: Fri Jul 1 09:12:00 2022 +0200

    tdf#56580 Fix negative error bars on log chart
    
    This is a bug in the rendering of negative error bars on log charts,
    when the error bar size is greater than the chart value. This is
    numerically invalid, since it leads to taking the logarithm of a
    non-positive value.
    - Add a test for this condition, and turn off the negative error bar
      when the condition is met.
    
    Change-Id: If84823c27d68976d3515581b1f913d78d683f446
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135106
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>
    Tested-by: Mike Kaganski <mike.kagan...@collabora.com>

diff --git a/chart2/source/view/charttypes/VSeriesPlotter.cxx 
b/chart2/source/view/charttypes/VSeriesPlotter.cxx
index 360bce2c275f..09e6860c3465 100644
--- a/chart2/source/view/charttypes/VSeriesPlotter.cxx
+++ b/chart2/source/view/charttypes/VSeriesPlotter.cxx
@@ -1045,7 +1045,21 @@ void VSeriesPlotter::createErrorBar(
                     fLocalX-=fLength;
                     aNegative = m_pPosHelper->transformLogicToScene( fLocalX, 
fLocalY, fZ, true );
                 }
-                bCreateNegativeBorder = m_pPosHelper->isLogicVisible( fLocalX, 
fLocalY, fZ);
+                if (std::isfinite(aNegative.PositionX) &&
+                        std::isfinite(aNegative.PositionY) &&
+                        std::isfinite(aNegative.PositionZ)) {
+                    bCreateNegativeBorder = m_pPosHelper->isLogicVisible( 
fLocalX, fLocalY, fZ);
+                } else {
+                    // If error bars result in a numerical problem (e.g., an
+                    // error bar on a logarithmic chart that results in a point
+                    // <= 0) then just turn off the error bar.
+                    //
+                    // TODO: This perhaps should display a warning, so the user
+                    // knows why a bar is not appearing.
+                    // TODO: This test could also be added to the positive 
case,
+                    // though a numerical overflow there is less likely.
+                    bShowNegative = false;
+                }
             }
             else
                 bShowNegative = false;

Reply via email to