2 people like it.

Chart NuGet package downloads

Quick script using FsLab that visualizes the aggregate number of downloads of a NuGet package over time, using the HTML type provider to get the data from www.nuget.org.

 1: 
 2: 
 3: 
 4: 
 5: 
 6: 
 7: 
 8: 
 9: 
10: 
11: 
12: 
13: 
14: 
15: 
16: 
17: 
18: 
19: 
20: 
open FSharp.Data
open XPlot.GoogleCharts
open Deedle

type N=HtmlProvider<"https://www.nuget.org/packages/FSharp.Data">

let packages = ["FSharp.Data"]
[ for pkg in packages ->
  let data = N.Load("https://www.nuget.org/packages/" + pkg)
  [for r in data.Tables.``Version History``.Rows -> r.``Last updated``, r.Downloads]
  |> Seq.groupBy fst
  |> Seq.map (fun (k, v) -> k, float(Seq.sumBy snd v))
  |> series
  |> Series.sortByKey
  |> Stats.expandingSum ]
|> Chart.Line
|> Chart.WithLabels packages
|> Chart.WithOptions(Options(trendlines=[| 
     Trendline(``type``="polynomial",lineWidth=4,opacity=0.3) |]))
|> Chart.WithTitle "F# Data downloads (aggregated)"
namespace Microsoft.FSharp
namespace Microsoft.FSharp.Data
type N = obj

Full name: Script.N
val packages : string list

Full name: Script.packages
val pkg : string
val data : obj
val r : obj
module Seq

from Microsoft.FSharp.Collections
val groupBy : projection:('T -> 'Key) -> source:seq<'T> -> seq<'Key * seq<'T>> (requires equality)

Full name: Microsoft.FSharp.Collections.Seq.groupBy
val fst : tuple:('T1 * 'T2) -> 'T1

Full name: Microsoft.FSharp.Core.Operators.fst
val map : mapping:('T -> 'U) -> source:seq<'T> -> seq<'U>

Full name: Microsoft.FSharp.Collections.Seq.map
val k : obj
val v : seq<obj * int>
Multiple items
val float : value:'T -> float (requires member op_Explicit)

Full name: Microsoft.FSharp.Core.Operators.float

--------------------
type float = System.Double

Full name: Microsoft.FSharp.Core.float

--------------------
type float<'Measure> = float

Full name: Microsoft.FSharp.Core.float<_>
val sumBy : projection:('T -> 'U) -> source:seq<'T> -> 'U (requires member ( + ) and member get_Zero)

Full name: Microsoft.FSharp.Collections.Seq.sumBy
val snd : tuple:('T1 * 'T2) -> 'T2

Full name: Microsoft.FSharp.Core.Operators.snd
Raw view New version

More information

Link:http://fssnip.net/tm
Posted:2 years ago
Author:Tomas Petricek
Tags: fslab , chart , html , type provider