Kaydet (Commit) 8d7a4416 authored tarafından Markus Mohrhard's avatar Markus Mohrhard

fixes and improvements for databar length calculation

Now min length and max length are also respected when the axis is in the
middle.

Additionally when the axis is in the middle we now scale the negative
and the positive part with the same factor. This is better for itnerop
and makes more sense.

Change-Id: If4c1adc0977d8ed66b8f22d937b0b3933288d012
üst 6439999f
...@@ -915,24 +915,41 @@ ScDataBarInfo* ScDataBarFormat::GetDataBarInfo(const ScAddress& rAddr) const ...@@ -915,24 +915,41 @@ ScDataBarInfo* ScDataBarFormat::GetDataBarInfo(const ScAddress& rAddr) const
nMinPositive = nMin; nMinPositive = nMin;
if (mpFormatData->mpUpperLimit->GetType() == COLORSCALE_MAX && nMax < 0) if (mpFormatData->mpUpperLimit->GetType() == COLORSCALE_MAX && nMax < 0)
nMaxNegative = nMax; nMaxNegative = nMax;
}
else if( mpFormatData->meAxisPosition == databar::MIDDLE)
pInfo->mnZero = 50;
//calculate the length //calculate the length
if(nValue < 0) if(nValue < 0)
{ {
if (nValue < nMin) if (nValue < nMin)
pInfo->mnLength = -100; pInfo->mnLength = -100;
else
pInfo->mnLength = -100 * (nValue-nMaxNegative)/(nMin-nMaxNegative);
}
else else
pInfo->mnLength = -100 * (nValue-nMaxNegative)/(nMin-nMaxNegative); {
if ( nValue > nMax )
pInfo->mnLength = 100;
else
pInfo->mnLength = (nValue-nMinPositive)/(nMax-nMinPositive)*100;
}
} }
else else if( mpFormatData->meAxisPosition == databar::MIDDLE)
{ {
if ( nValue > nMax ) pInfo->mnZero = 50;
pInfo->mnLength = 100; double nAbsMax = std::max(std::abs(nMin), std::abs(nMax));
if (nValue < 0)
{
if (nValue < nMin)
pInfo->mnLength = -nMaxLength;
else
pInfo->mnLength = nMaxLength * (nValue/nAbsMax);
}
else else
pInfo->mnLength = (nValue-nMinPositive)/(nMax-nMinPositive)*100; {
if (nValue > nMax)
pInfo->mnLength = nMaxLength;
else
pInfo->mnLength = nMaxLength * (nValue/nAbsMax);
}
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment