Home
Options

updating results

is there no way to update plots or results after they are visible without fiddling with events or similar?

var chart = new Chart();
(...)

PanelManager.DisplayControl(chart, "Chart");  // seems exactly like chart.Dump();

for (,,){
    series.Points.AddY(newValue);
    Thread.Sleep(100);
}

this example will never display anything as it won't finish.

Comments

  • Options

    LINQPad's fluent charting API doesn't allow for this, but the underlying WinForms charting control does. Hence you can do this:

    var customers = new[]
    {
        new { Name = "John", TotalOrders = 100 },
        new { Name = "Mary", TotalOrders = 130 },
        new { Name = "Sara", TotalOrders = 140 },
        new { Name = "Paul", TotalOrders = 125 },
    };
    
    var chart = customers.Chart (c => c.Name, c => c.TotalOrders);
    var winChart = chart.ToWindowsChart().Dump();
    
    await Task.Delay (1000);
    
    winChart.Series [0].Points.Add (175).AxisLabel = "Alice";
    

    Note that you must use await Task.Delay rather than Sleep, otherwise the message loop that renders the chart will be blocked.

  • Options

    great! await Task.Delay (time); did the trick!

    assuming my infinite example

    do {
        series.Points.AddY(ran.Next());
        await Task.Delay(200);
    } until (Console.Readkey....)
    

    I tried some but Linqpad behaves differently than console app. What would be the recommended way to interact with running Linqpad code?

Sign In or Register to comment.