Charts disappear immediately after being displayed.
I'm seeing a weird behavior I'm trying to make sense of, and I'm hoping someone here might have some insight.
I should start by saying that if I load up the samples Charting examples in linqpad 5 or 6 and run them things work fine. The charts display and everything is as expected. The behavior described below happens in both of the most recent versions of linqpad 5 and 6.
I recently created a linqpad doc that connected to an influxdb instance, fetched a set of data through a query, turned it into a list of anonymous records, and then I tried to chart it with a fairly simple .Chart()
and .Dump()
call. The behavior I see is that the chart is displayed, no errors are shown, but then just a few brief moments later, the chart tab clears to a default background.
DumpInline()
works fine. And .Dump()
works fine in the simpler cases shown in the samples where the data is all local arrays.
I don't think I missed anything in the documentation about how to use chart, but I'm hoping someone will point out what I am doing wrong.
EDIT I just found something that may help explain something. I ran this one last time, this time as a non maximized window (I was thinking of capturing it as a gif to include here), and saw the same thing as before, the chart content disappears. But then I moved the linqpad window and the chart is there - floating on my desktop behind the linqpad instance. This is starting to smell like a bug, and not user error - has anyone else seen this?
I don't know if it matters but this is all being done through a remote desktop session as I can't access the influxdb from where I am. I have a vague memory of rdp having an effect on how graphics operations are carried out, at least in the distant past.
The document in question looks like the below:
<Query Kind="Statements"> <NuGetReference>Vibrant.InfluxDB.Client</NuGetReference> <Namespace>Vibrant.InfluxDB.Client</Namespace> <Namespace>Vibrant.InfluxDB.Client.Rows</Namespace> <RemoveNamespace>System.Collections</RemoveNamespace> <RemoveNamespace>System.Collections.Generic</RemoveNamespace> <RemoveNamespace>System.Data</RemoveNamespace> <RemoveNamespace>System.Diagnostics</RemoveNamespace> <RemoveNamespace>System.IO</RemoveNamespace> <RemoveNamespace>System.Linq.Expressions</RemoveNamespace> <RemoveNamespace>System.Reflection</RemoveNamespace> <RemoveNamespace>System.Text</RemoveNamespace> <RemoveNamespace>System.Text.RegularExpressions</RemoveNamespace> <RemoveNamespace>System.Threading</RemoveNamespace> <RemoveNamespace>System.Transactions</RemoveNamespace> <RemoveNamespace>System.Xml</RemoveNamespace> <RemoveNamespace>System.Xml.Linq</RemoveNamespace> <RemoveNamespace>System.Xml.XPath</RemoveNamespace> </Query> using var client = new InfluxClient(new Uri("http://server:8086")); var res = await client.ReadAsync<DynamicInfluxRow>("logs", @" select count(Assembly) from logs.autogen.Logs where and time >= '2019-12-04' and level = 'Error' group by time(1d) "); var data = res.Results[0].Series[0].Rows.Select(item => new { item.Timestamp, Value = item .Fields["count"]}).ToList(); data.Chart(c => c.Timestamp).AddYSeries(c => c.Value, LINQPad.Util.SeriesType.Line).Dump();
Comments
Do you get the same problem if you run the following query:
That works fine, on Linqpad 5 and 6, both on my local machine and over the RDP session I used earlier.
below is a screen capture of what happens with the original influxdb generated graph.
I have tried to recreate this with simpler scripts, for instance, just plotting a bunch of timestamped random values and that works perfectly.
That is as far as I can see basically the same plotting as in the one that acts weird. Makes me think that something about the actual running of the query is introducing the issue, but I don't have any idea how.
Update -
If I put your
GridTest
test after the originalChart().Dump()
calls, then they both disapear and end up floating off screen. But only when the influxdb calls are there, if its just a plot or a gridtest by itself, it works fine.Is there anything relevant in %localappdata%\linqpad\Logs.LINQPad6\logs.txt?
I suspect the charting control is throwing some kind of exception or hanging in a way that prevents LINQPad from sizing and positioning its form.
I'm afraid not. That folder is empty after running the query in question. Sorry.
I too am experiencing this issue. Maybe it has something to do with async/await? I'm calling a weather api with the HttpClient using async/await and parsing the results using System.Text.Json.JsonSerializer using async/await. But, if I remove the
async Task
from the Main method and call.Result
from my async call, the chart shows just fine.Nothing in the logs for me either, unfortunately.
I was able to reproduce the issue using this code:
This is a different problem: the controls end up being created on a non-UI thread after awaiting. You can fix it by adding the following code to your query before awaiting:
That solved it. Thank you!