Anyone know how to format the labels in a NumericXAxis via code behind.
I am creating the axis with the code below but cannot figure out how to format the integer lables into a date time string.
NumericXAxis xmXAxis = new NumericXAxis();
xmXAxis .LabelSettings.Extent = 55;
xmXAxis .LabelSettings.Location = AxisLabelsLocation.OutsideLeft;
xmXAxis .MinimumValue = 0;
xmXAxis .MajorStroke = DarkBrush;
xmXAxis .MajorStrokeThickness = 1;
xmXAxis .MinorStrokeThickness = 0;
Chart1.Axes.Add(xmXAxis);
Thanks for any help!
I would suggest just create a new collection and covert your integers to dates
before adding them to that collection to feed the chart.
Thanks, Just got it with the code below
xmXAxis.LabelSettings.Extent = 35;
xmXAxis.LabelSettings.Location = AxisLabelsLocation.OutsideBottom;
xmXAxis.Label = Resources["DateAxisLabel"];
xmXAxis.MinorStrokeDashArray = new DoubleCollection();
xmXAxis.MinorStrokeDashArray.Add(1);
xmXAxis.MajorStroke = DarkBrush;
xmXAxis.MajorStrokeThickness = 2;
xmXAxis.MinorStroke = LightBrush;
xmXAxis.MinorStrokeThickness = 1;
xmXAxis.MinimumValue = GetUnixEpoch(MinDate);
xmXAxis.MaximumValue = GetUnixEpoch(MaxDate);
xmXAxis.Interval = 1;
XAML
<UserControl.Resources>
<models:EpochToDateStringConverter x:Key="EpochToDateStringConverter" />
<DataTemplate x:Key="DateAxisLabel">
<TextBlock Text="{Binding Path=Item, Converter={StaticResource EpochToDateStringConverter}}" Margin="0" Padding="0"></TextBlock>
</DataTemplate>
</UserControl.Resources>