diff --git a/src/historygraph.cpp b/src/historygraph.cpp index 9c3522f3..5b958e0c 100644 --- a/src/historygraph.cpp +++ b/src/historygraph.cpp @@ -135,6 +135,9 @@ void AHistoryGraph::Update ( ) // store current date for reference curDate = QDate::currentDate(); + // set oldest date to draw + QDate minDate = curDate.addDays ( MAX_DAYS_HISTORY * -1 ); + // get oldest date in history QDate oldestDate = curDate.addDays ( 1 ); // one day in the future const int iNumItemsForHistory = vHistoryDataFifo.Size(); @@ -150,6 +153,10 @@ void AHistoryGraph::Update ( ) } } } + if (oldestDate < minDate) + { + oldestDate = minDate; + } const int iNumDaysInHistory = -curDate.daysTo ( oldestDate ) + 1; // draw frame of the graph @@ -159,7 +166,7 @@ void AHistoryGraph::Update ( ) for ( i = 0; i < iNumItemsForHistory; i++ ) { // only use valid dates - if ( vHistoryDataFifo[i].DateTime.date().isValid() ) + if ( vHistoryDataFifo[i].DateTime.date().isValid() && oldestDate <= vHistoryDataFifo[i].DateTime.date() ) { AddMarker ( vHistoryDataFifo[i] ); } diff --git a/src/historygraph.h b/src/historygraph.h index 47038599..86c42221 100644 --- a/src/historygraph.h +++ b/src/historygraph.h @@ -44,7 +44,9 @@ /* Definitions ****************************************************************/ // number of history items to store -#define NUM_ITEMS_HISTORY 600 +#define NUM_ITEMS_HISTORY 4800 +// oldest item to draw +#define MAX_DAYS_HISTORY 60 /* Interface ******************************************************************/