LinqPad and F# Charting
Import these references
Sample script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// Must be run in LINQPAD 4 - gives missing method exception in linqpad 5 | |
let dc = new TypedDataContext() | |
open System | |
open System.IO | |
open XPlot.GoogleCharts | |
open XPlot.Plotly | |
open XPlot.GoogleCharts.Data | |
open XPlot.GoogleCharts.Configuration | |
open XPlot.Plotly.HTML | |
let getAge (d : DateTime) = | |
let result = DateTime.Today.Year - d.Year | |
// printfn "%i" result | |
result | |
let query = query | |
{ | |
for row in dc.Clients do | |
select row | |
//take 1000 | |
} | |
let ages = query | |
|> Seq.map (fun row -> getAge(row.DateOfBirth.GetValueOrDefault(DateTime.Today))) | |
|> Seq.filter (fun x -> x > 0) | |
|> Seq.filter (fun x -> x < 100) | |
|> Seq.map(fun x-> "Client ages" , x) | |
//ages.Count() |> Dump | |
Chart.Histogram ages | |
|> Chart.WithOptions (Options(title = "Client Ages")) | |
|> Chart.WithLabel "Total" | |
|> Chart.Show | |
|> ignore |
Graph
Published: