Skip to content

Commit

Permalink
Updating Chart on homepage to show stats of package downloads/hour.
Browse files Browse the repository at this point in the history
  • Loading branch information
pranavkm committed Mar 9, 2011
1 parent 591c0a1 commit 9065099
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 20 deletions.
35 changes: 18 additions & 17 deletions ChartTemplate.xml
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
<Chart BackColor="#D3DFF0" BackGradientStyle="TopBottom" BackSecondaryColor="White" BorderColor="26, 59, 105" BorderlineDashStyle="Solid" BorderWidth="2" Palette="BrightPastel">
<ChartAreas>
<ChartArea Name="Default" _Template_="All" BackColor="64, 165, 191, 228" BackGradientStyle="TopBottom" BackSecondaryColor="White" BorderColor="64, 64, 64, 64" BorderDashStyle="Solid" ShadowColor="Transparent">
<AxisY>
<LabelStyle Format="{0:0,0}" />
<MajorGrid Enabled="True" LineDashStyle="Dash" />
<MinorGrid Enabled="False" />
</AxisY>
<AxisX LineColor="64, 64, 64, 64">
<MajorGrid Enabled="False" />
<MinorGrid Enabled="False" />
</AxisX>
</ChartArea>
</ChartAreas>
<Legends>
<Legend _Template_="All" BackColor="Transparent" Font="Trebuchet MS, 8.25pt, style=Bold" IsTextAutoFit="False" />
</Legends>

<ChartAreas>
<ChartArea Name="Default" _Template_="All" BackColor="64, 165, 191, 228" BackGradientStyle="TopBottom" BackSecondaryColor="White" BorderColor="64, 64, 64, 64" BorderDashStyle="Solid" ShadowColor="Transparent">
<AxisY>
<LabelStyle Format="{0:0,0}" />
<MajorGrid Enabled="True" LineDashStyle="Dash" />
<MinorGrid Enabled="False" />
</AxisY>
<AxisX LineColor="64, 64, 64, 64">
<LabelStyle Format="{0:ddd d, HH:mm}" />
<MajorGrid Enabled="False" />
<MinorGrid Enabled="False" />
</AxisX>
</ChartArea>
</ChartAreas>
<Legends>
<Legend _Template_="All" BackColor="Transparent" Font="Trebuchet MS, 8.25pt, style=Bold" IsTextAutoFit="False" />
</Legends>

</Chart>
12 changes: 9 additions & 3 deletions viewstats.cshtml
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
@{
var stats = NuGetStatistics.GetStatsHistory(1000);
var stats = NuGetStatistics.GetStatsHistory(100);
var statDiffs = new List<object>();
dynamic previous = stats.Last();
foreach (var current in stats.Reverse().Skip(1)) {
statDiffs.Add(new { Downloads = current.Downloads - previous.Downloads, LogTime = (DateTime)current.LogTime });
previous = current;
}

var chart = new Chart(600, 300, themePath: "ChartTemplate.xml")
.AddSeries(chartType: "Line", xValue: stats, xField: "LogTime", yValues: stats, yFields: "Downloads")
.AddSeries(chartType: "Spline", xValue: statDiffs, xField: "LogTime", yValues: statDiffs, yFields: "Downloads")
.AddTitle("Downloads")
.SetYAxis(min: 130000)
.Write(format: "png");
}

0 comments on commit 9065099

Please sign in to comment.