Search code examples
f#f#-interactivefsharpchart

FSharp.Charting shows separated window for each Chart in interactive mode


When I try to evaluate the following code in F# interactive console I get three separated chart windows (one for chartA, one for chartB and one for combined chart). How to prevent of displaying chart every time it's created? I want to display only the combined chart in single chart window.

let chartA = setA |> Chart.Point |> Chart.WithSeries.Style(System.Drawing.Color.Orange)
let chartB = setB |> Chart.Point |> Chart.WithSeries.Style(System.Drawing.Color.Gold)
let chartC = Chart.Combine [|chartA; chartB|]

Solution

  • You can use scope

    let chartC = 
        let chartA = setA |> Chart.Point |> Chart.WithSeries.Style(System.Drawing.Color.Orange)
        let chartB = setB |> Chart.Point |> Chart.WithSeries.Style(System.Drawing.Color.Gold)
        Chart.Combine [|chartA; chartB|]
    

    Or without the locals

    let chartC (setA:seq<float*float>) (setB:seq<float*float>) = 
        [| setA |> Chart.Point |> Chart.WithSeries.Style(System.Drawing.Color.Orange) ;
           setB |> Chart.Point |> Chart.WithSeries.Style(System.Drawing.Color.Gold) |]
        |> Chart.Combine