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.
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
Mike,
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.
Graham,
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?