How can we get the X axis labels to line up on an even time interval, such as 5 minute intervals?
The graph includes:
- A numeric X axis - multiple numeric Y axes.- multiple ScatterLineSeries - Series data in an observable collection of datapoints having - Date time - date time of the data point (computed by StartTime + elapsed minutes) - The X axis is bound to this - Elapsed minutes - number of minutes from the start time (double) - Start time - DateTime of the first data point in the series (DateTime) - DataValue - value to display on the chart (double) - The Y axis is bound to this The data points are collected in real time and can come in at any time. The first data point in the series will be on an odd boundary, such as 3:41:20pm, instead of a rounded 3:30:00pm.
What we want is the X axis to start on an even boundary, such as 3:40:00pm and have labels at even intervals, 3:45:00pm, 3:50:00pm, 3:55:00pm...
We cannot use a CategoryDateTimeXAxis because the data points do not fall on even boundaries (i.e., there is no nicely aligned time value to bind the X axis to and the number of data points in a given time interval may vary).
The X axis labels in the middle of the chart are not on even boundaries if you set the X axis minimum or maximum or both.
Is there a way to make the Numeric X axis labels occur on even 5 minute boundaries?
Can this be accomplished by adding a hidden ScatterLineSeries with data points on 5 minute intervals and use that data series as the one the X axis uses for its labels?The numeric X axis should let us set the interval for labels since it appears that Infragistics will arbitrarily map the label to a nearby data point's X value. That mapping does not work well for evenly spacing labels and for a consistent user interface especially when zooming in.
The help has: In NumericXAxis, data is treated as continuously varying numerical labels, and the marker is placed at a point along the X-axis which varies according to the value in a data column that is mapped using the XMemberPath property of Scatter Series.
Thank you for the sample project. It helps for static data. We graph real time data and need to have X axis labels aligned on even time boundaries, such as 5 minutes.
Setting the X axis min and max works as long as you do not zoom in / out or let the user set a user defined minimum and maximum.
Users of our graphs need to:
-- set an X axis minimum and maximum with arbitrary values -- have the X axis labels fall on even time boundaries (e.g., 12:35 pm instead of 12:34:41 pm) -- have the X axis labels fall on even time boundaries when the user zooms in -- have the X axis labels fall on even time boundaries when new data is added to the end of the graph (usually 1 new data point per series at about every 1 second but not guaranteed to be on the second).
It would help greatly if we could set a label interval for the X axis that would be used when zooming in at various levels.
1 hour, 30 minutes, 15 minutes, 5 minutes, 1 minute, 30 seconds, 15 seconds, 5 seconds, 1 second, 1/2 second, 1/4 second, 1/10 second, 1/20 second, 1/100 second
It would select the appropriate label interval based on:
Z = amount of time visible in the current chart window (accounts for zoom)Z = Z / 2 //to let at least two labels show on the graph if possibleLabel_Interval = largest label interval that is less than or equal to ZLabel_interval = smallest allowed label interval (1/100 second) if Z < smallest allowed label interval
Hello,
I have been looking into your issue and I have created a sample application(DataChartRealData.zip) using the provided code. To set start date as 12:00 I have set the ‘MinimumValue’ of the XAxis to “start.AddMinutes(-2).AddSeconds(-31).Ticks” and its ‘MaximumValue’ to “start.AddMinutes(2).Ticks”.
For 5 minutes interval I have set its ‘Interval’ property to “3000000000”.
If you have any other questions on this matter, feel free to ask.
Here is a sample application main window c# and XAML. We want to set the X axis to start on an even 5 minute boundary and also have 5 minute intervals between X axis labels. The out of the box behavior appears to not let us set a starting value for the X axis and an interval that matches a date/time boundary. In other words, when showing more than a hour of real time collected data, we do not want to show the end user odd time icrement labels such as 12:37:32.
using System;using System.Collections.ObjectModel;using System.Windows;
namespace ScatterWithTextOnXAxis{ /// <summary> /// Interaction logic for MainWindow.xaml /// </summary> public partial class MainWindow : Window { public MainWindow() { InitializeComponent();
DateTime start = new DateTime(2012, 04, 17, 12, 32, 31, 0); ObservableCollection<Data> graphData = new ObservableCollection<Data>();
graphData.Add(new Data{ Y = 1, TimeValue = start });
//we want the first X axis label to start on 12:30pm on Apr 17, 2012 //we want the other X axis labels on the graph to be on even 5 minute boundaries //New data points would be added to the collectio about 1 each second (but not guaranteed on each and every second)
int ctr = 1; graphData.Add(new Data { Y = ctr++ * 5, TimeValue = start}); start= start.AddMinutes(0.63) ; graphData.Add(new Data { Y = ctr++ * 5, TimeValue = start}); start= start.AddMinutes(1.13) ; graphData.Add(new Data { Y = ctr++ * 5, TimeValue = start}); start= start.AddMinutes(0.23) ; graphData.Add(new Data { Y = ctr++ * 5, TimeValue = start}); start= start.AddMinutes(0.56) ; graphData.Add(new Data { Y = ctr++ * 5, TimeValue = start}); start= start.AddMinutes(0.90) ; graphData.Add(new Data { Y = ctr++ * 5, TimeValue = start}); start= start.AddMinutes(1.42) ; graphData.Add(new Data { Y = ctr++ * 5, TimeValue = start}); start= start.AddMinutes(0.03) ; graphData.Add(new Data { Y = ctr++ * 5, TimeValue = start}); start= start.AddMinutes(0.24) ; graphData.Add(new Data { Y = ctr++ * 5, TimeValue = start}); start= start.AddMinutes(1.55) ; graphData.Add(new Data { Y = ctr++ * 5, TimeValue = start}); start= start.AddMinutes(0.34) ; graphData.Add(new Data { Y = ctr++ * 5, TimeValue = start}); start= start.AddMinutes(0.78) ; graphData.Add(new Data { Y = ctr++ * 5, TimeValue = start}); start= start.AddMinutes(0.90) ; graphData.Add(new Data { Y = ctr++ * 5, TimeValue = start}); start= start.AddMinutes(0.21) ; graphData.Add(new Data { Y = ctr++ * 5, TimeValue = start}); start= start.AddMinutes(2.63) ; graphData.Add(new Data { Y = ctr++ * 5, TimeValue = start}); start= start.AddMinutes(0.04) ; graphData.Add(new Data { Y = ctr++ * 5, TimeValue = start}); start= start.AddMinutes(0.37) ; graphData.Add(new Data { Y = ctr++ * 5, TimeValue = start}); start= start.AddMinutes(1.60) ; graphData.Add(new Data { Y = ctr++ * 5, TimeValue = start}); start= start.AddMinutes(0.63) ; graphData.Add(new Data { Y = ctr++ * 5, TimeValue = start});
DataContext = graphData; } }
public class Data { public double X { get { return TimeValue.Ticks; } } public double Y { get; set; } public DateTime TimeValue { get; set; } }}
<Window xmlns:ig="http://schemas.infragistics.com/xaml" x:Class="ScatterWithTextOnXAxis.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Height="350" Width="525" xmlns:local="clr-namespace:ScatterWithTextOnXAxis"> <Grid> <ig:XamDataChart> <ig:XamDataChart.Axes> <ig:NumericXAxis x:Name="xAxis" /> <ig:NumericYAxis x:Name="yAxis" /> </ig:XamDataChart.Axes> <ig:XamDataChart.Series> <ig:ScatterLineSeries ItemsSource="{Binding}" XAxis="{Binding ElementName=xAxis}" YAxis="{Binding ElementName=yAxis}" XMemberPath="X" YMemberPath="Y"/> </ig:XamDataChart.Series> </ig:XamDataChart> </Grid></Window>
I am checking if this is still an issue for you.
If you require any further assistance please do not hesitate to ask.
I have been looking into your issue and would you please, if possible, send me an isolated sample application following your scenario in order to provide you with more accurate assistance ?
Looking forward to hearing from you.