I would like to do some basic charting in F# using build in features or a free library. And I would be very very pleased with a very basic example of it, a pie chart if possible.
Example data :
[("John",34);("Sara",30);("Will",20);("Maria",16)]
Where the ints are percentages to be represented in the pie.
I have recently installed VSLab and though I find a lot of 3D examples, I am only looking for a simple pie chart...
It is also fine to use excel features by the way, not free, but installed nevertheless..
It's easy to do "made in home" pie chart: open System.Drawing
Originally I only tried to complement ssp's example here with a very simple windows form dialog which shows a pie. But trying this I found a bug in ssp's code: on the one hand
Seq.pairwise
operates onvals
instead ofangles
and on the other hand it obviously doesn't consider that pie slices will be drawn beginning from start angle along sweep angle.I corrected the bug, commented, rearranged, reformatted and renamed some things - and made it both
#load
-able in fsi.exe and compilable with fsc.exe:Last but not least I want to mention two helpful hints I found useful
List.scan
Here's something I smashed together using the Google Chart API, I hope the code is clear enough without further explanation:
Old question, but technology changing.
in vs 2013, F# 3, and installing the nuget Package
Add reference to:
and with one line of code:
The following F# code generate the bie chart:
and you get the following chart: