How to render in HTML5 a chart made with FSharp.Charting?

307 views Asked by At

There doesn't seem to be any documentation around this capability from the FSharp.Charting library, which is briefly mentioned in the main webpage in this paragraph:

F# Charting is designed so that the same charting specifications can be supported when using different charting implementations. For example, the Try F# charts use similar charting specifications, implemented using in HTML5 using Dojo Charts.

Any sample around that I can follow?

1

There are 1 answers

0
Tomas Petricek On

The documentation is not very clear - what it is trying to say is that F# Charting does not support HTML5, but you can use other libraries that do.

The most advanced one is probably XPlot, which provides wrappers over Google Charts and Plot.ly and in both of the cases, you can get the HTML representation of the chart (and do whatever you want with it).

For example, I used it to display chart in a Suave-based web site:

open XPlot.GoogleCharts

// Create a chart - the API is similar to F# Charting
let chart = Chart.Pie [ for r in results -> r.Option, r.Votes ] 
// Get the HTML of the chart (you also need to load Google Charts in JavaScript)
let html = chart.InlineHtml