If there are multiple players on a chart is it possible to have a unified tooltip that displays the current Y value of each layer currently in contact with the vertical crosshair without having to have the cursor touching each layer individually?
Mike,Here's how you might use the NumericXAxis to have greater control over the time labels that are displayed.This sample pushes the minimum and maximum so that an even number of minutes is represented in the range.Then it sets the interval equal to 20 seconds. So a tickmark will be displayed every 20 seconds. Is this more what you are after?Hopefully the CategoryDateTimeXAxis will soon also support your scenario, but it doesnt currently allow for you to have this degree of configuration.The Xaml:
<UserControl.Resources> <local:TicksToDateTime x:Key="converter" /> </UserControl.Resources> <Grid x:Name="LayoutRoot" Background="White"> <ig:XamDataChart Name="xamDataChart1" HorizontalZoomable="True" VerticalZoomable="True"> <ig:XamDataChart.Axes> <ig:NumericXAxis x:Name="xAxis" > <ig:NumericXAxis.Label> <DataTemplate> <TextBlock Text="{Binding Path=Item, Converter={StaticResource converter}, ConverterParameter='hh:mm:ss'}" /> </DataTemplate> </ig:NumericXAxis.Label> </ig:NumericXAxis> <ig:NumericYAxis x:Name="yAxis" MinimumValue="0" MaximumValue="8" /> </ig:XamDataChart.Axes> <ig:XamDataChart.Series> <ig:ScatterLineSeries x:Name="scatter" XAxis="{Binding ElementName=xAxis}" YAxis="{Binding ElementName=yAxis}" XMemberPath="XValue" YMemberPath="YValue" /> </ig:XamDataChart.Series> </ig:XamDataChart> </Grid>
And the code behind:
public partial class MainPage : UserControl { public MainPage() { InitializeComponent(); DateTimeData data = new DateTimeData(); NumericXAxis a = xamDataChart1.Axes.OfType<NumericXAxis>().First(); DateTime s = data[0].XValue; DateTime e = data[data.Count - 1].XValue; //push the min and max to be on even minute values. s = new DateTime(s.Year, s.Month, s.Day, s.Hour, s.Minute, 0 , 0); e = new DateTime(e.Year, e.Month, e.Day, e.Hour, e.Minute + 1, 0, 0); a.MinimumValue = s.Ticks; a.MaximumValue = e.Ticks; //set the gridline/label interval to 20 seconds. a.Interval = TimeSpan.FromSeconds(20).Ticks; xamDataChart1.Series[0].ItemsSource = data; } } public class TicksToDateTime : IValueConverter { public object Convert( object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { if (value is double && targetType == typeof(string)) { string param = parameter as string; double val = (double)value; if (!string.IsNullOrEmpty(param)) { return new DateTime((long)val) .ToString(param, culture.DateTimeFormat); } else { return new DateTime((long)val) .ToString(culture.DateTimeFormat); } } return ""; } public object ConvertBack( object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { throw new NotImplementedException(); } } public class DateTimeData : ObservableCollection<DateTimeDataItem> { public DateTimeData() { for (int i = 0; i < 100; i++) { Add(new DateTimeDataItem() { XValue = DateTime.Now.AddSeconds(i), YValue = i % 6 }); } } } public class DateTimeDataItem { public DateTime XValue { get; set; } public double YValue { get; set; } }
Hope this helps! Please note the scatter line chart's performance is currently not as good as line series, so make sure it is still a good fit for your scenario.Let me know if you have any questions.-Graham
Crap...it seems there is always something in the way of cmpleting this task.
So, if I need something where I can control the number of axis lables/interval, the labels display as dates but also need 10 seconds to look smaller than 60 seconds what axis type would most closely accomplish those goals? Can I use numeric axis and just override how the labels are displayed or will I run into other issues?
Mike
Unfortunately, it doesn't look to me like the CategoryDateTimeXAxis currently supports a user defined interval. I would suggest making a feature request: http://devcenter.infragistics.com/protected/requestfeature.aspx
I imagine its already on the roadmap, but casting your votes should raise its priority.
-Graham
Graham, your provided solution works perfect for me. This is exactly that what I am searching for.
In addition I also tried to configure the count of the grid lines for the X-Axis (no matter if CategoryDateTimeXAxis or not), but with no success. Therefore I also want to know how to handle this.
Thanks Graham.
I didn't realize I was getting the datetime in the number of ticks...I should have guessed. I saw some negative values and thought there was an error. Thanks!
On a similar issue, is there a way to specify how many major grid lines/labels are displayed using the CategoryDateTimeXAxis? I seem to always get 10.