In this tutorial we will walk through creating a chart in the browser,
from an F# script running in Visual Studio Code.
We assume that:
First, create a new F# script file: Script.fsx
.
Copy-paste the following code into the editor:
#r "nuget: XPlot.Plotly"
open XPlot.Plotly
[ 1 .. 10 ] |> Chart.Line |> Chart.Show
Select all of the code you pasted in and press Alt
+Enter
to execute it.
That's it! You should see a chart popping up in your browser.
Notes
- you will need an internet connection for the chart to render, as the code relies on Plotly.
namespace XPlot
namespace XPlot.Plotly
type Chart =
static member Area : data:seq<#value> -> PlotlyChart + 2 overloads
static member Bar : data:seq<#value> -> PlotlyChart + 2 overloads
static member Bubble : data:seq<#key * #value * #value> -> PlotlyChart
static member Candlestick : data:seq<#key * #value * #value * #value * #value> -> PlotlyChart
static member Column : data:seq<#value> -> PlotlyChart + 2 overloads
static member Line : data:seq<#value> -> PlotlyChart + 2 overloads
static member Pie : data:seq<#key * #value> -> PlotlyChart
static member Plot : data:Trace -> PlotlyChart + 3 overloads
static member Scatter : data:seq<#value> -> PlotlyChart + 2 overloads
static member Show : chart:PlotlyChart -> unit
...
static member Chart.Line : data:seq<#seq<'a1 * 'a2>> -> PlotlyChart (requires 'a1 :> key and 'a2 :> value)
static member Chart.Line : data:seq<#key * #value> -> PlotlyChart
static member Chart.Line : data:seq<#value> -> PlotlyChart
static member Chart.Show : chart:PlotlyChart -> unit
val x : PlotlyChart
member PlotlyChart.GetHtml : unit -> string