Profile Picture

Prevent graph update while adding data

Posted By Joël Golinucci 10 Years Ago
Author
Message
Joël Golinucci
Posted 10 Years Ago
View Quick Profile
Junior Member

Junior Member (18 reputation)Junior Member (18 reputation)Junior Member (18 reputation)Junior Member (18 reputation)Junior Member (18 reputation)Junior Member (18 reputation)Junior Member (18 reputation)Junior Member (18 reputation)Junior Member (18 reputation)

Group: Forum Members
Last Active: 9 Years Ago
Posts: 30, Visits: 61
Hi,

I would like to know what is the best way to update a large quantity of NRangeSeries into a graph without freezing the whole application.
Knowing that the graph will be updated every 5 seconds (maybe less)

I thought of 2 options :

1) Disable the graph refresh, clear all values from the graph, add the new values and fillstyles, re-enable the graph refresh
2) As the points will be the same each time but only the colors will change, only update the fill styles


For option 1, I'm a bit lost between all these nevron objects and I don't really know where to look for the refresh disable/enable property (the NChartControl, the NChart or the NRangeSeries object) ?

For option 2, I'm not sure that using the FillStyles is the best thing to do. For each point I would like to be able to define an associated color corresponding to a value not depending on the coordinates. Now each time I add a new point, I do it this way:


For Each pt As tGraphPoint In ptLst
fRangeSeries.Values.Add(pt.Z) 'Nevron Y start - Deepth (Z axis)
fRangeSeries.Y2Values.Add(pt.Z + 2) 'Nevron Y end
fRangeSeries.XValues.Add(pt.X) 'Nevron X start - Horizontal (X axis)
fRangeSeries.X2Values.Add(pt.X + 1) 'Nevron X end
fRangeSeries.ZValues.Add(pt.Y) 'Nevron Z start - Vertical (Y axis)
fRangeSeries.Z2Values.Add(pt.Y + 1) 'Nevron Z end
i += 1
fRangeSeries.FillStyles.Add(i, New NColorFillStyle(GetColorFromValue(pt.Value, plotVariable)))
Next


But when comes the time to refresh what is the best thing to do ? Clear FillStyles and only add the new ones or is there a way to replace the specific color for a given coordinate ?

Thanks for your help,
Regards,

Joël

Nevron Support
Posted 10 Years Ago
View Quick Profile
Supreme Being

Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)

Group: Forum Members
Last Active: Yesterday @ 1:54 AM
Posts: 3,054, Visits: 4,009
Hi Joel,

1. In order to turn off automatic refresh you only need to write:

nChartControl1.AutoRefresh = false;

Adding values is achieved most efficiently when you use the AddRange method - for example:

rangeSeries.Values.Clear();
rangeSeries.Values.AddRange(values);

where values in this case is a double[] array. Same applies for fill styles.

2. You can update the colors in the fill style using code similar to:

int count = rangeSeries.FillStyles.Count;
for (int i = 0; i < count; i++)
{
NColorFillStyle colorFill = rangeSeries.FillStyles[i] as NColorFillStyle;

if (colorFill != null)
{
colorFill.Color = someNewColor;
}
}

This will be more efficient that using new in order to update each new fill style.

Let us know if you meet any problems or have any questions.

Best Regards,
Nevron Support Team





Similar Topics


Reading This Topic