0

Using FSharp.Charting from a .fs program, when a plot is displayed it blocks the execution of rest of the program. Is there a way to generate non blocking charts? E.g. I would want both the following to be displayed in separate windows and also have the rest of the program execute.

Chart.Line(Series1) |> Chart.Show // Chart 1
// do some work
Chart.Line(Series2) |> Chart.Show // display this in a second window
// continue executing the rest while the above windows are still open.
4

1 に答える 1

0

通話方法について詳しく教えていただけますChart.Lineか? たとえば、REPL で、FSLab 経由で、winforms で、wpf で?

fsx ファイルで作業している場合、以下はブロックしません。もう 1 つの方法は、非同期ブロックでラップすることです。これは、長時間実行される計算を行っている場合やデータベースにアクセスしている場合に役立ちます。

#load @"..\..\FSLAB\packages\FsLab\FsLab.fsx"
open Deedle
open FSharp.Charting
open System

let rnd = System.Random()
let xs = List.init 100 (fun _ -> rnd.NextDouble() - 0.5)
let xs' =  List.init 100 (fun _ -> rnd.NextDouble() - 0.5)

Chart.Line(xs) // |> Chart.Show 
Chart.Line(xs') //|> Chart.Show

追加:

async {Chart.Line(xs)  |> Chart.Show } |> Async.Start 
async {Chart.Line(xs') |> Chart.Show } |> Async.Start

MS DocsF# Fun&Profit

コンパイル例:

open System
open FSharp.Charting
open System.Threading
open System.Threading.Tasks
open System.Drawing
open FSharp.Charting
open FSharp.Charting.ChartTypes



[<STAThread>]
[<EntryPoint>]
let main argv = 
    let rnd = System.Random()
    let xs = List.init 100 (fun _ -> rnd.NextDouble() - 0.5)
    let xs' =  List.init 100 (fun _ -> rnd.NextDouble() - 0.5)


    Chart.Line(xs)  |> Chart.Show 
    printfn "%A" "Chart 1"
    Chart.Line(xs') |> Chart.Show
    printfn "%A" "Chart 2"

    async {Chart.Line(xs)  |> Chart.Show } |> Async.Start 
    printfn "%A" "Chart 3"
    async {Chart.Line(xs') |> Chart.Show } |> Async.Start
    printfn "%A" "Chart 4"
    Console.Read() |> ignore
    printfn "%A" argv
    0 // return an integer exit code
于 2016-09-04T23:36:03.773 に答える