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.
We did extensive investigation of this and whether or not it was worth it to access the not-acessable interval property in the axis via a custom dependency property.
Can the xamDataChart control be updated for the real-world scenario of real-time data acquisition for a time based X-Axis as well as an elapsed minutes X-Axis?
Both of those would not work with a category X Axis because there may be a variable time gap between data points.
This would help the real-world use of having multiple Y-axes and a single time or elapsed minutes based X-axis
We had to do the following complex solution for xamDatachart v12.1 on WPF:
- Set numeric X axis minimum and maximum to align the min/max visible with even number/time boundaries- Set numeric Y axis minimum and maximum to align the min/max visible with even number/time boundaries
- Override the TickMarkValues and generate by hand - the labels visible (major tickmark values) on the X and Y axes - the minor tickmark values for X and Y axes- Handle multiple graph related events (zoom, redraw axis panel, etc) to call the custom code to regenerate the major and minor tickmark values
This is overly complex in that we need to have business logic in our view model to handle user settable values (e.g., major/minor interval, starting value, ending value) as well as ones at the view level (major and minor tickmarks, start and end rounding).
--Recommendation--This could much more simply be handled if xamDatachart allowed a numeric X or Y axis to have a custom virtual method to let the user override the minimum and maximum visible (i.e., allow rounding to even numbers) as well as set the interval for major tickmarks/labels and the interval for minor tickmarks.
This would be much easier than having each part done in different event handlers.
Infragistics could help greatly if it was in this form and called by the graph control when needed (i.e., zoom, pan, new data added causing axis visible range to change, ...)
void GenerateVisibleAxisLabelsTickmarks(NumericAxisBase axis, ref double startingVisibleValue, ref double endingVisibleValue, ref double majorInterval, ref double minorInterval)
{ //values passed in are current values for the axis (eigther a numeric Y or numeric X axis
//round startingVisibleValue down to the nearest multiple of ...1000, 100, 10, 1/10, 1/100, ...
//round endingVisibleValue up the the nearest multiple of ...1000, 100, 10, 1/10, 1/100, ...
//round majorInterval to be divisible into the range (endingVisibleValue - startingVisibleValue)
//round minorInterval to be divisible into majorInterval
if (it is an X axis and X axis is time based) (i.e., it is using time.ticks for its values, which are then convereted to a date/time via a label converter)
{
//round to x hours, 1 hour 30 minutes, 15 minutes, 10 minute, 5 minutes, 1 minute, 30 seconds, 15 seconds, 10 seconds, 5 seconds, 1 second, 1/10 second, 1/100 second, ...
}
This is what is needed to handle a graph with dynamically added data where data is added at non-uniform intervals.
any solution for this issue? i am having the same problem
Jason,
Unfortunately the only way you can customize the labelling on the CategoryDateTimeXAxis at present is through the manipulation of the min/max/interval, but this doesn't allow you to shorten the first interval of the axis.
If you always want to snap the values in certain ways we'll need to provide you a customization hook by which you can decide where to place each gridline and label. The NumericXAxis actually has this, you can override its "TickmarkValues" and returrn a list of positions to label/gridline. You could actually use the NumericXAxis for labelling, if you desire, even if you don't associate it with the series you are displaying. You could set its minimum and maximum equal to the tick value of the actual min and max of the date time x axis, and then override the TickmarkValues in order to have fine grained control over which labels get displayed. The other piece of the puzzle would be to use a converter with the axis to convert the ticks values into the appropriate date time strings.
Doing the above would be somewhat complicated, but is achievable. As an alternative option, you could make a feature request for the labelling behavior you are trying to achieve. There is a "calendar axis" on our backlog I believe, which may be defined to support features such as this, but the more feature requests we receive the more it should help set the backlog priority.
-Graham
Graham,
Thanks for the reply. I do have MinimumValue and MaximumValue available to me, but using these as a solution to my problem proved to be inadequate. I don't want to limit the range of data that's visible, I just want to alter the labeling. Also, even if I set the min and max, zooming on the chart presents the same problems with labeling that I've had. Is there any way to specify a label start offset?
Thanks,
Jason