Home
Insert
Update snippet 'Analysing signatures of 2nd EU referendum petition'
Title
Description
The snippet looks at the number of signatures for the petition to do a second Brexit referendum. It uses JSON type provider to parse the data from the web site & Google charts to visualize the results.
Source code
open Deedle open FSharp.Data open XPlot.GoogleCharts // Download the number of signitures from the petition GOV web site // See: https://petition.parliament.uk/petitions/131215 type Ref = JsonProvider<"https://petition.parliament.uk/petitions/131215.json"> let ref = Ref.GetSample() // Look at signatures by country - sorting the data shows // that there is -3605 signatures from Andorra :-/ ref.Data.Attributes.SignaturesByCountry |> Seq.map (fun i -> i.Name, i.SignatureCount) |> series |> Series.sort |> Series.rev // Draw a chart of signatures coming from non-UK countries let ca = ColorAxis(colors=[|"#30d020"; "#e0e030"; "#e08030"; "#ff3000" |]) ref.Data.Attributes.SignaturesByCountry |> Seq.filter (fun i -> i.Name <> "United Kingdom") |> Seq.map (fun i -> i.Name, i.SignatureCount) |> Chart.Geo |> Chart.WithOptions(Options(colorAxis=ca))
Tags
f# data
fslab
jsonprovider
xplot
f# data
fslab
jsonprovider
xplot
Author
Link
Reference NuGet packages
If your snippet has external dependencies, enter the names of NuGet packages to reference, separated by a comma (
#r
directives are not required).
Update