2

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|]
cezarypiatek
  • 1,078
  • 11
  • 21

1 Answers1

4

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
Funk
  • 10,976
  • 1
  • 17
  • 33
  • It seems to work. Could you provide explanation why these approaches do the trick? – cezarypiatek Nov 11 '16 at 11:52
  • 2
    @cezarypiatek With your approach each line gets evaluated separately in F# Interactive, generating a `Chart` for each. In my approach the entire block following the `let` is evaluated at once and only the result gets plotted. – Funk Nov 11 '16 at 12:12