Hi,
I’m having some problems plotting a graph with pointmetadata. Every time the graph updates, it seems like the id’s of the metadata are different (giving each point new metadatas). Looking at both lists, the count of both are way off and both vary a lot on each update. Shouldn’t both of those lists always match with each other? What could be the problem?
- Jonathan Janesjö asked 7 years ago
-
Hi Daniel, my first question is “How are you updating the chart?”
- You must login to post comments
Hi Andrew,
Oh, I’ve already done quite a few changes to it already and to be honest I don’t know how the policy for sharing code is at my company.
I work for a games company and I use SciChart to plot player data on a graph that represents a top-view of a map. The X and Y coordinates of the graph are used as world-coordinates of the level and I use PointMetaData to store FrameTime and Value (of the data plotted). In the updates I just filtered out data points based on either FrameTime or Value (based on user imput). The code used to be something like this:
var ds = new XyDataSeries<double, double>();
foreach (var point in myPoints)
{
if (point.FrameTime < minFrameTime || point.FrameTime > maxFrameTime) continue;
ds.Append(point.X, point.Y, new myPointMetaData(point.Value));
}
MyRenderableSeries.DataSeries = ds;
Now I’m just creating one DataSeries once with all the points, sending FrameTime along with the value as a PointMetaData and doing this filtering inside the PointMaker instead. It seems to do the job quite well and the count of the MetaData now always matches the count of points in the DataSeries (= reliable data displayed). I’m only trying to find how to trigger a Re-Draw/Refresh of the graph once I update properties on my PointMaker.
- Jonathan Janesjö answered 7 years ago
-
OK fair enough! To trigger a redraw, you can call MyRenderableSeries.OnInvalidateParentSurface(), or dataSeries.InvalidateParentSurface()
-
Thank for the great support Andrew! You’re always fast on your replies and spot on too. :)
- You must login to post comments
Hi Andrew,
I’ve been digging into it a bit more and think I’ve found the problem. I’m “updating the chart” by looping through my data, creating a new DataSeries and assigning it to the existing RenderableSeries. When that is done, the old DataSeries seems to be replaced by the new one but the MetaData that belonged to the old DataSeries never gets deleted, so the MetaData of the new DataSerier is just appended to the end of the list. Using RenderableSeries.DataSeries.Metadata.Clear() just breaks the list (no new values are added after that).
I’m in the process of changing how this update is done, so a DataSeries is only assigned to a RenderableSeries once and then I do the same “filtering” that I was doing previously in my custom PointMaker instead. Hope this works better (and faster, since I can reuse either the loop done in the MoveTo or the Draw one).
- Jonathan Janesjö answered 7 years ago
- last edited 7 years ago
-
Hi Daniel, can you share the code for updating the dataseries so we can have a look at it? We might be able to suggest something.
- You must login to post comments
I messed up the upload of the attachment the first time….
- Jonathan Janesjö answered 7 years ago
- You must login to post comments
Please login first to submit.