Initial commit: simple example.
This commit is contained in:
parent
14a8de37ab
commit
36300cd6a4
|
@ -0,0 +1,57 @@
|
|||
// reference the type provider dll
|
||||
#r "./packages/SQLProvider/lib/FSharp.Data.SqlProvider.dll"
|
||||
open FSharp.Data.Sql
|
||||
|
||||
// static (compile time) ResolutionPath and ConnectionString
|
||||
let [<Literal>] ResolutionPath = __SOURCE_DIRECTORY__ + @"/lib"
|
||||
let [<Literal>] ConnectionString = "Data Source="
|
||||
+ __SOURCE_DIRECTORY__ + @"/data/extensions.sqlite;Version=3"
|
||||
|
||||
|
||||
|
||||
// create a type alias with the connection string and database vendor settings
|
||||
type Sql = SqlDataProvider<
|
||||
ConnectionString = ConnectionString,
|
||||
DatabaseVendor = Common.DatabaseProviderTypes.SQLITE,
|
||||
ResolutionPath = ResolutionPath,
|
||||
IndividualsAmount = 500,
|
||||
UseOptionTypes = true >
|
||||
|
||||
let Ctx = Sql.GetDataContext() // ResolutionPath,ConnectionString) // dynamic ResolutionPath and ConnectionString
|
||||
|
||||
let getDownloads extid = query {
|
||||
for order in Ctx.Main.Extension do
|
||||
where (order.Extid = Some extid)
|
||||
select (order.Date, order.Downloads)
|
||||
} |> Seq.filter (fun (date, download) -> date.IsSome && download.IsSome)
|
||||
|> Seq.map (fun (date, download) -> (System.DateTime.Parse(date.Value),
|
||||
download.Value))
|
||||
|> Seq.toArray
|
||||
|
||||
let customers =
|
||||
Ctx.Main.Extension
|
||||
|> Seq.map(fun c -> c.Extid)
|
||||
|> Seq.toList
|
||||
|
||||
|
||||
#load "packages/FsLab/Themes/DefaultWhite.fsx"
|
||||
#load "packages/FsLab/FsLab.fsx"
|
||||
|
||||
open Deedle
|
||||
open FSharp.Data
|
||||
open XPlot.GoogleCharts
|
||||
open XPlot.GoogleCharts.Deedle
|
||||
|
||||
let ExtIds = ["aaagbdompnfgjaokopkpaceijcapjdde"
|
||||
"aaahoedfmconkhncmkajlkallgnkjibh"
|
||||
"aaahpjmadckbgmdbflcgblcnimbpfefg"
|
||||
"aaaidlpoefeeklbhpndokmfipimojimj"
|
||||
"aaaikdbhdiebhdogngakgnmjgpkpcmln"
|
||||
]
|
||||
|
||||
(List.map (fun e -> (series (getDownloads e))) ExtIds)
|
||||
|> Chart.Line
|
||||
|> Chart.WithOptions (Options(legend=Legend(position="bottom")))
|
||||
|> Chart.WithLabels ExtIds
|
||||
|
||||
|
Loading…
Reference in New Issue