I have a UltraDataChart with a CategoryDateTimeXAxis and a NumericYAxis. I need a scrolling window of view-able time on the chart. How can I show only the last 5 minutes of data in the chart's view-able area, but be able to pan and see the points which are outside the 5 minute window?
Hi Jared,
This is do-able, essentially what you will need to do is set the ultraDataChart1.HorizontalZoomable = true, and possibly the VerticalZoomable = true, if that is your desired viewstyle. Then you will need to set the WindowRect to show a viewport to that of your last 5 minutes. The biggest difficulty will be around the math of calculating the size of that WindowsRect. That difficulty will compound if you are on a constant live feed, that maintains it's entire history. This is because the WindowRect is essentially percentage of the whole. IE, If you want to show the whole chart the WindowRect will have a position of X=0, Y=0, Width=1, Height=1. But if you have a history of 50 minutes, and only want to show the last 5 minutes, for it's full height. You would have a X=.9, Y=0, Width=.1, Height=1. You may also want to look into the WindowRectMinWidth property to keep people zooming closer than 5 minutes. To assist with the calculations each axis has a GetScaledValue and GetUnscaledValue method. An example of it's use in a similar scenario can be found here:
http://www.infragistics.com/community/forums/t/103200.aspxLet me know if that helps,
Thanks Mike! Your suggestions to alter the WindowRect was just what I needed. I basically calculate the percentage of desired time to total chart time. Since I have a live feed of data, I do this every time I get a new point in. I am adding a code snippet for anyone who happens to be looking for this functionality later.
//Get handle to chart's datasource
BindingList<ChartPoint> points = dataChrtComparison.Series[0].DataSource as BindingList<ChartPoint>;
//Get time span of entire chart TimeSpan totalTime = points.Last().Time - points.First().Time; if (totalTime > TimeSpan.FromMinutes(5)) {
//Set width of chart's viewport to the percentage of desired viewable timespan to total time var rect = dataChrtComparison.WindowRect; rect.Width = 5 / totalTime.TotalMinutes;
//Set location of viewport to end of total chart. rect.X = 1 - rect.Width; dataChrtComparison.WindowRect = rect;
}
Would it be correct to assume that the UltraDataChart has no integrated scrollbars as the UltraChart did? If I put in my own scroll bars to control the WindowRect, is there an event I can access when the user zooms in or out with the chart? The UltraDataChart.WindowRectChanged event does not seem to be triggered when I zoom in or out (using my mouse wheel e.g.).