I have a realtime chart that I am re-coding in WPF from Silverlight. When I did this in Silverlight, as I added points, the xaxis major stroke lines stayed fixed but the labels updated (the labels were timestamps). Is there any build in way to make the major axis lines slowly move across the screen as time progresses? I am currently using the NumericXAxis buy I could also use the CategoryDateTimeXAxis if that makes a difference.
Hello Mike,
To get the axis lines to move in time you can use a DispatcherTimer and add items to the DataSource in the Tick event. I have attached a sample.
Duane,
I took a look at the sample but it isn't exactly what I was looking for. I probably did not mention that the min time needs to move as well. In Silverlight I used a Queue to enqueue a new va;ue and dequeue the first value which worked out nicely except the major axis line stayed fixed and the times they represented changed. Now in WPF I am doing things a little different. I have a collection I keep adding to and simply change the MinimumValue and MaximumValue of the x-axis to the time window I am looking at. This still has the same effect where the major axis lines stay fixed and the times update. Is there a way to move both the Minimum and Maximum x-axis values and have the major axis line move?
I have been looking into your requirement and since there is no supported functionality for that I had modified Duane’s sample to achieve the behavior you desire using an animation approach of my own (xamDataChart1_modified.zip).
Please let me know if you require any clarification on my implementation.
Thanks Petar. This is pretty close to what I want to accomplish. I am a little confused though about the WindowPositionHorizontal property. I thought that was a value between 0 and 1. In your sample you just keep adding 0.1 to it every half second right? How exactly is that working? What does that number actually represent?
If I wanted the major axis lines to always fall on specific intervals of time such as every 10 seconds, is that going to be a calculation nightmare?
Hi Mike,
You are right the values are between 0 and 1 and represent the position. The position actually represents the left border of the thumb. Since I wanted to keep the scroll to the rightmost and since the constant axis range changes were overriding the position I had to add to it a value that would go a little over 1, so this seemed easiest.
Regarding “If I wanted the major axis lines to always fall on specific intervals of time such as every 10 seconds, is that going to be a calculation nightmare?” I am really not sure you have in mind. Please explain this in more details and if possible with some screenshots. Also I’d like to point out that the sample always show the same amount of data between 20 units of measurement on the X axis.
Looking forward to hearing from you.
I am just checking if you got this worked out, or you still require any assistance, or clarification on the matter.
If this is what you were looking for please verify the answer so it helps other users as well.
You can choose between using a CategoryDateTimeAxis that is meant for DateTime values, or use numeric values with NumericXAxis and format only the labels to be shown as DateTime values. Here is forum post of mine that shows both in a single sample project: http://ko.infragistics.com/community/forums/t/70620.aspx . In regards to the calculations there shouldn’t be much to it, only the scale animation should be adjust to show the proper percentage of data. Please update me with a sample of yours that is going to be used, so we can continue working on the exactly same thing.
Sorry, I was a little vague. Since my x axis will be time I would like the labels being displayed to be proper interval times such as 12:30:15, 12:30:30, 12:30:45. Right now you sample would take the current time and then show 20 seconds (my unit of time) and there would be 4 major axis lines. The lines would be something like 12:30:11, 12:30:16, 12:30:21, etc. I would prefer to have the axis labels display 12:30:10, 12:30:15, 12:30:20. Point being, not only do I need to calculate the position, scale and range of the axis to make it scroll but I also need to configure it so that the label for each major or minor axis line displays a time that is divisible by 5.
Does that make sense? I can try to create a screenshot if not.
Thanks,
Mike