Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
350
How to visualize the current position of a movie in a LineChart dynamically?
posted

In a program, I want to show a movie and the audience ratings at the same time. So I created a little movie player with a LineChart on it. During the movie plays, a slider moves from left to right. In order to illustrate the current position, I place a vertically line on the chart, which is on the same position as the slider.

The processing:
1. A timer control fires every 10 ms.
2. In the timer_tick event, I reposition the slider button and invalidate the chart (via InvalidateLayers)
3. InvalidateLayers causes the FillSceneGraph event.
4. Inside FillSceneGraph I paint a red line. Here the source code:

public void Chart_FillSceneGraph(object sender, Infragistics.UltraChart.Shared.Events.FillSceneGraphEventArgs e)
{
 IAdvanceAxis axisX = e.Grid["X"] as IAdvanceAxis;
 IAdvanceAxis axisY = e.Grid["Y"] as IAdvanceAxis;
 double dLength = (double)axisX.Maximum - (double)axisX.Minimum;
 int xStart = (int)axisX.Map((int)(dLength * _Movie_Track.Value / _Movie_Track.Maximum));
 int xEnd = xStart;
 int yStart = (int)axisY.Map(axisY.Minimum);
 int yEnd = (int)axisY.Map(axisY.Maximum);
 
 _targetLine = new Line(new Point(xStart, yStart), new Point(xEnd, yEnd));
 _targetLine.PE.Stroke = Color.Red;
 _targetLine.PE.StrokeWidth = 1;
 e.SceneGraph.Add(_targetLine);
}

 

It works ok, but with big data (3 series, each 30000 datapoints) it works quite slow (plobably due to the multiple InvalidateLayer calls). So my question:
Is this the recommended way to do this or is there another (faster) alternative?

 

 

Parents Reply Children
No Data