summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sc/source/core/data/colorscale.cxx6
1 files changed, 4 insertions, 2 deletions
diff --git a/sc/source/core/data/colorscale.cxx b/sc/source/core/data/colorscale.cxx
index 4652587a1641..cf55990a2a6e 100644
--- a/sc/source/core/data/colorscale.cxx
+++ b/sc/source/core/data/colorscale.cxx
@@ -912,13 +912,15 @@ ScDataBarInfo* ScDataBarFormat::GetDataBarInfo(const ScAddress& rAddr) const
else
pInfo->mnZero = 0;
+ double nMinNonNegative = std::max(0.0, nMin);
+ double nMaxNonPositive = std::min(0.0, nMax);
//calculate the length
if(nValue < 0 && nMin < 0)
{
if (nValue < nMin)
pInfo->mnLength = -100;
else
- pInfo->mnLength = -100 * (nValue-nMax)/(nMin-nMax);
+ pInfo->mnLength = -100 * (nValue-nMaxNonPositive)/(nMin-nMaxNonPositive);
}
else
{
@@ -927,7 +929,7 @@ ScDataBarInfo* ScDataBarFormat::GetDataBarInfo(const ScAddress& rAddr) const
else if (nValue <= nMin)
pInfo->mnLength = 0;
else
- pInfo->mnLength = 100 * (nValue-nMin)/(nMax-nMin);
+ pInfo->mnLength = 100 * (nValue-nMinNonNegative)/(nMax-nMinNonNegative);
}
}
else if( mpFormatData->meAxisPosition == databar::MIDDLE)