Is there a way to force the x-axis to display labels at specific interval? For example if the x-axis is a DateTime and goes from 11:23AM to 1:39PM but I only want to show labels at 11:30, 11:45, 12:00, 12:15, etc, is there a way to do this?
At the moment, the way to solve this is to set the Axis.Unit to 15 minutes, then to round the Axis.Minimum value down to the nearest 15 minutes, e.g., if the x-axis needs to cover a period starting from 11:23AM, then rounding down to the nearest 15 minutes, we set the Axis.Minimum to 11:15AM. Then labels will occur at 11:15, 11:30, 11:45, etc.
Though that's not exactly the customization you described, additional customization features for things such as labels are always being considered as we plan future releases.
I tried to use the Unit, minimum, and maximum properties as you mentioned but it does not appear to be exposed on the DataChart object. Does this same suggestion also hold true for the XamDataChart (I am not using the XamWebChart)? The best I can come up with is the interval property which does not guarantee my label will be on the rounded time I am hoping for.
Mike,
I'm not sure if even the CategoryDateTimeXAxis will help keep your label intervals rounded if you are removing and adding the points in real time. You can set an interval, but if x axis span isn't evenly divisible by the interval then your labels will fall on non even values. I believe there may be some smart snapping features in our backlog for the CategoryDateTimeXAxis, but you may want to make a feature request also. Its important to note that the CategoryDateTimeXAxis does not let you manually set the minimum and maximum values currently, so you couldn't keep those updated along with the data to ensure the span was evenly divisible.
From my testing, there may be an floating point arithmetic issue with the CategoryDateTimeXAxis currently if your first and last values are very close together in terms of ticks, as may be your case. If you can send us a sample of how you have it configured, we can identify any potential bugs and try and assert that the scenario works for the first service release of the chart, or earlier if it is only a configuration issue.
Graham,
I have created a messy sample to demonstrate what I am trying to do but using the CategoryXAxis. If I simple change the x axis to CategoryDateTimeAxis (and add the DateTimeMemberPath and DisplayType) then nothing works any longer. Queuing/Dequeuing seem to always be invalid index (although that seems to be ok in my full app), the HoveredCategoryItems behavior does not work and nothing shows up on the chart. Can you tell me where I should dent the sample as I cannot attach it here?
Mike
Did you mean you can't find how to attach it or you are unable to attach it? The file attachment options are on the option tab when you are posting. You can also email files to gmurray@infragistics.com
Ah, I should have looked a little harder...I have attached it now.
Did my sample makes sense as to what I was trying to do (or have you had a chance to take a look at it yet)? Is there something else I am missing in order to use the CategoryDateTimeXAxis?
The above bug is resolved, you must be encountering a different issue. Could you provide a sample that illustrates your problem?
Is there a target date for when this bug will be fixed? We're also running into the same issue with the CategoryDateTimeXAxis where the X label no longer shows up when we set DisplayType="Discrete". Already downloaded & install the latest service release for 10.3 (NetAdvantage_WPF_20103.2116_SR.exe) but the labels are still missing.
Sorry for the late response, I've been out of the office. Here is a workaround you can use to make the axis function correctly with short time intervals, until the fix is released.The Xaml:
<UserControl.Resources> <local:TimeTranslator x:Key="translator" /> </UserControl.Resources> <Grid x:Name="LayoutRoot" Background="White"> <Grid.RowDefinitions> <RowDefinition /> </Grid.RowDefinitions> <ig:XamDataChart Name="xamDataChart1" VerticalZoomable="True" HorizontalZoomable="True" > <ig:XamDataChart.Axes> <ig:CategoryDateTimeXAxis x:Name="xAxis" ItemsSource="{Binding}" DateTimeMemberPath="Date"> <ig:CategoryDateTimeXAxis.Label> <DataTemplate> <TextBlock Text="{Binding Item.Date, Converter={StaticResource translator}}" /> </DataTemplate> </ig:CategoryDateTimeXAxis.Label> </ig:CategoryDateTimeXAxis> <ig:NumericYAxis x:Name="yAxis" /> </ig:XamDataChart.Axes> <ig:XamDataChart.Series> <ig:LineSeries x:Name="testLine" ItemsSource="{Binding}" XAxis="{Binding ElementName=xAxis}" YAxis="{Binding ElementName=yAxis}" ValueMemberPath="Value" /> </ig:XamDataChart.Series> </ig:XamDataChart> </Grid>
And the code behind:
public partial class MainPage : UserControl { private DispatcherTimer _timer = new DispatcherTimer(); public MainPage() { InitializeComponent(); DataContext = new TestData(); _timer.Interval = new TimeSpan(0,0,0,0,250); _timer.Tick += timer_Tick; _timer.Start(); } void timer_Tick(object sender, EventArgs e) { ((TestData)DataContext).AddPoint(); } } public class TestDataItem { public DateTime Date { get; set; } public double Value { get; set; } } public class TimeTranslator : IValueConverter { private static DateTime _progStartTime = DateTime.Now; public static DateTime Translate(DateTime from) { return new DateTime(((from - _progStartTime).Ticks * 170000) + _progStartTime.Ticks); } public static DateTime UnTranslate(DateTime from) { return new DateTime(((from - _progStartTime).Ticks / 170000) + _progStartTime.Ticks); } public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { if ((targetType == typeof(DateTime) || (targetType == typeof(string))) && value is DateTime) { return UnTranslate((DateTime)value); } return DateTime.MinValue; } public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { throw new NotImplementedException(); } } public class TestData : ObservableCollection<TestDataItem> { public TestData() { for (int i = 0; i < 100; i++) { AddPoint(); } } private static Random rand = new Random(); int _i; double _curr; public void AddPoint() { if (rand.NextDouble() > .5) { _curr += rand.NextDouble(); } else { _curr -= rand.NextDouble(); } Add( new TestDataItem() { Date = TimeTranslator.Translate(DateTime.Now), Value = _curr }); _i++; } }
-Graham
I'll see if I can come up with some sort of work around you can use in the meantime. I've fixed this bug and marked it resolved but it has not gone through quality assurance yet, The changes should be available in the next service release for the product. You should be able to contact support and product management and see if you might be able to get some early builds to help you out, and this would assist us in ensuring your other scenarios are well covered.
I have been trying to work around the CategoryDateTimeXAxis problem by increasing the interval time between points but so far no interval seems to make any difference. Can you help me get around this issue? What is the potential turn around time for bugs? We are in process of purchasing this package with support. Will that help get updated code with some of these bugs fixed?