private BarGraph GraphQueueStatus()
{
int[] totals = new int[24];
int[] counts = new int[24];
DateTime max = DateTime.Now;
DateTime min = max - TimeSpan.FromDays( 7.0 );
for ( int i = 0; i < m_QueueStats.Count; ++i )
{
DateTime ts = m_QueueStats[i].TimeStamp;
if ( ts >= min && ts < max )
{
DateTime date = ts.Date;
TimeSpan time = ts.TimeOfDay;
int hour = time.Hours;
totals[hour] += m_QueueStats[i].Count;
counts[hour]++;
}
}
BarGraph barGraph = new BarGraph( "Average pages in queue", "graph_pagequeue_avg", 10, "Time", "Pages", BarGraphRenderMode.Lines );
barGraph.FontSize = 6;
for ( int i = 7; i <= totals.Length+7; ++i )
{
int val;
if ( counts[i%totals.Length] == 0 )
val = 0;
else
val = (totals[i%totals.Length] + (counts[i%totals.Length] / 2)) / counts[i%totals.Length];
int realHours = i%totals.Length;
int hours;
if ( realHours == 0 )
hours = 12;
else if ( realHours > 12 )
hours = realHours - 12;
else
hours = realHours;
barGraph.Items.Add( hours + (realHours >= 12 ? " PM" : " AM"), val );
}
return barGraph;
}