diff options
author | Kurt Nordback <kurt.nordback@protonmail.com> | 2022-05-28 15:29:31 -0600 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2022-07-01 09:12:00 +0200 |
commit | ec31df481568f6a654e5f6c1d597dc8b963b99e6 (patch) | |
tree | 163077e6167956aa5d1387ad313375df1d4b3a42 /chart2 | |
parent | 184a45c4176d96bf799a8f8a0fba290a8c851948 (diff) |
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.kaganski@collabora.com>
Tested-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'chart2')
-rw-r--r-- | chart2/source/view/charttypes/VSeriesPlotter.cxx | 16 |
1 files changed, 15 insertions, 1 deletions
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; |