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.
Hello,
I am checking if this is still an issue for you.
If you require any further assistance please do not hesitate 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>