Kaydet (Commit) 58d05f5a authored tarafından Markus Mohrhard's avatar Markus Mohrhard Kaydeden (comit) Andras Timar

tdf#42915, NaN in a date axis can destroy the whole chart

The NaN value forces the scaling of the axis to be based on years
and introduces gaps in the rendering.

Reviewed-on: https://gerrit.libreoffice.org/64267
Tested-by: Jenkins
Reviewed-by: 's avatarMarkus Mohrhard <markus.mohrhard@googlemail.com>

related tdf#42915, pass NaN through date transformation

Many places in chart2 use NaN to mean no available value. Not propagating
NaN through the helper disables all this functionality.

Reviewed-on: https://gerrit.libreoffice.org/64266
Tested-by: Jenkins
Reviewed-by: 's avatarMarkus Mohrhard <markus.mohrhard@googlemail.com>
Reviewed-on: https://gerrit.libreoffice.org/64304
(cherry picked from commit 55c53825)
Reviewed-on: https://gerrit.libreoffice.org/64310Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
(cherry picked from commit 0a906dc7)

Change-Id: I78219be289d76edb53b5672209e1c031ab62def9
37f966007b5b7cc16778c5c6903710fbd144631b
üst 7e011f03
...@@ -69,6 +69,9 @@ bool DateHelper::IsLessThanOneYearAway( const Date& rD1, const Date& rD2 ) ...@@ -69,6 +69,9 @@ bool DateHelper::IsLessThanOneYearAway( const Date& rD1, const Date& rD2 )
double DateHelper::RasterizeDateValue( double fValue, const Date& rNullDate, long TimeResolution ) double DateHelper::RasterizeDateValue( double fValue, const Date& rNullDate, long TimeResolution )
{ {
if (rtl::math::isNan(fValue))
return fValue;
Date aDate(rNullDate); aDate.AddDays(::rtl::math::approxFloor(fValue)); Date aDate(rNullDate); aDate.AddDays(::rtl::math::approxFloor(fValue));
switch(TimeResolution) switch(TimeResolution)
{ {
......
...@@ -757,7 +757,12 @@ void AreaChart::createShapes() ...@@ -757,7 +757,12 @@ void AreaChart::createShapes()
//collect data point information (logic coordinates, style ): //collect data point information (logic coordinates, style ):
double fLogicX = (*aSeriesIter)->getXValue(nIndex); double fLogicX = (*aSeriesIter)->getXValue(nIndex);
if (bDateCategory) if (bDateCategory)
{
if (rtl::math::isNan(fLogicX))
continue;
fLogicX = DateHelper::RasterizeDateValue( fLogicX, m_aNullDate, m_nTimeResolution ); fLogicX = DateHelper::RasterizeDateValue( fLogicX, m_aNullDate, m_nTimeResolution );
}
double fLogicY = (*aSeriesIter)->getYValue(nIndex); double fLogicY = (*aSeriesIter)->getYValue(nIndex);
if( m_nDimension==3 && m_bArea && rSeriesList.size()!=1 ) if( m_nDimension==3 && m_bArea && rSeriesList.size()!=1 )
......
...@@ -1462,10 +1462,17 @@ long VSeriesPlotter::calculateTimeResolutionOnXAxis() ...@@ -1462,10 +1462,17 @@ long VSeriesPlotter::calculateTimeResolutionOnXAxis()
aNullDate = m_apNumberFormatterWrapper->getNullDate(); aNullDate = m_apNumberFormatterWrapper->getNullDate();
if( aIt!=aEnd ) if( aIt!=aEnd )
{ {
while (rtl::math::isNan(*aIt) && aIt != aEnd)
{
++aIt;
}
Date aPrevious(aNullDate); aPrevious.AddDays(rtl::math::approxFloor(*aIt)); Date aPrevious(aNullDate); aPrevious.AddDays(rtl::math::approxFloor(*aIt));
++aIt; ++aIt;
for(;aIt!=aEnd;++aIt) for(;aIt!=aEnd;++aIt)
{ {
if (rtl::math::isNan(*aIt))
continue;
Date aCurrent(aNullDate); aCurrent.AddDays(rtl::math::approxFloor(*aIt)); Date aCurrent(aNullDate); aCurrent.AddDays(rtl::math::approxFloor(*aIt));
if( nRet == css::chart::TimeUnit::YEAR ) if( nRet == css::chart::TimeUnit::YEAR )
{ {
......
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