Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
FsiBot Data Science Prototype
#r "System.Windows.Forms.DataVisualization.dll"
#r @"..\packages\FSharp.Charting.0.90.7\lib\net40\FSharp.Charting.dll"
#r @"..\packages\FSharp.Data.2.0.14\lib\net40\FSharp.Data.dll"
open FSharp.Data
open FSharp.Charting
let wb = WorldBankData.GetDataContext()
type Indicator = Runtime.WorldBank.Indicator
type Indicators = WorldBankData.ServiceTypes.Indicators
[<AutoOpen>]
module Countries =
let uk = wb.Countries.``United Kingdom``.Indicators
let fr = wb.Countries.France.Indicators
let de = wb.Countries.Germany.Indicators
// ....
let (/.) (a:Indicator) (b:Indicator) =
(Chart.Combine
[Chart.Line(a,a.Code+" "+a.Name);
Chart.Line(b,b.Code+" "+b.Name)] )
.WithLegend()
.ShowChart()
let (|.) (a:Indicator) (b:Indicator) =
(Chart.Combine
[Chart.Column(a,a.Code+" "+a.Name);
Chart.Column(b,b.Code+" "+b.Name)] )
.WithLegend()
.ShowChart()
let (=>) (xs:Indicators seq) (f:Indicators -> Indicator) =
(Chart.Combine
(xs |> Seq.map(fun x ->
let i = f x
Chart.Line(i,i.Code+" "+i.Name))))
.WithLegend()
.ShowChart()
// What you send to FsiBot:
uk.``GDP (constant 2005 US$)`` /. fr.``GDP (constant 2005 US$)``
uk.``Energy related methane emissions (% of total)`` /. fr.``Energy related methane emissions (% of total)``
uk.``GDP (constant 2005 US$)`` |. fr.``GDP (constant 2005 US$)``
[uk;fr;de] => (fun i -> i.``GDP (constant 2005 US$)``)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.