Merge pull request #13 from pljones/feature/covid19-date-limit-on-historygraph
Enhance historygraph to allow size based on date
This commit is contained in:
commit
f605c35935
2 changed files with 11 additions and 2 deletions
|
@ -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] );
|
||||
}
|
||||
|
|
|
@ -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 ******************************************************************/
|
||||
|
|
Loading…
Reference in a new issue