I have a problem where setting the MaximumTicks on a DateTimeContinousAxis causes the Bars on a BarSeries to be drawn incorrectly for large numbers of bars. Below is an example showing the problem.
If you run the example, you can see that initially the bars correspond to the line series plotting the same data (ignoring the aliasing effect of too many bars for the number of pixels to display them on). However, you have way too many labels to display on the X axis, and a solid grey background due to the number of grid lines.
Now, use the box at the bottom to change the value of MaximumTicks (note that this is the first time it's being set). Now the bars do not appear to correspond to the line series. (My theory is that they're being drawn way too wide.) The labels and grid lines now look good, however.
Now drag the right zoom handle on the horizontal axis as far left as possible (maximum zoom at the start of the series). You see similar effects to the zoomed out view.
Now, again use the box at the bottom to change the value of MaximumTicks and the display goes back to what is expected. Now you can zoom back out, and you still have the expected view where the bars match the line.
Is there another way to filter down the number of labels and grid lines and get the bars to draw at a reasonable width? I tried GapLength, but this didn't resolve the problem (0.95 looks much better, but they're still overlapping a bit, 0.5 looks the same as without).
Thanks,
Louis
XAML:
Code Behind:
If you run the example, you can see that initially the bars correspond to the line series plotting the same data (ignoring the aliasing effect of too many bars for the number of pixels to display them on). However, you have way too many labels to display on the X axis, and a solid grey background due to the number of grid lines.
Now, use the box at the bottom to change the value of MaximumTicks (note that this is the first time it's being set). Now the bars do not appear to correspond to the line series. (My theory is that they're being drawn way too wide.) The labels and grid lines now look good, however.
Now drag the right zoom handle on the horizontal axis as far left as possible (maximum zoom at the start of the series). You see similar effects to the zoomed out view.
Now, again use the box at the bottom to change the value of MaximumTicks and the display goes back to what is expected. Now you can zoom back out, and you still have the expected view where the bars match the line.
Is there another way to filter down the number of labels and grid lines and get the bars to draw at a reasonable width? I tried GapLength, but this didn't resolve the problem (0.95 looks much better, but they're still overlapping a bit, 0.5 looks the same as without).
Thanks,
Louis
XAML:
<Window x:Class="BarDensity.MainWindow" xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation" xmlns:local="clr-namespace:BarDensity" Title="MainWindow" Height="750" Width="1000"> <Grid> <Grid.RowDefinitions> <RowDefinition Height="*"/> <RowDefinition Height="Auto"/> </Grid.RowDefinitions> <telerik:RadCartesianChart Margin="5" x:Name="PropertyChart"> <telerik:RadCartesianChart.Behaviors> <telerik:ChartPanAndZoomBehavior ZoomMode="Both" PanMode="Both" /> </telerik:RadCartesianChart.Behaviors> <telerik:RadCartesianChart.Grid> <telerik:CartesianChartGrid MajorLinesVisibility="XY" /> </telerik:RadCartesianChart.Grid> <telerik:RadCartesianChart.HorizontalAxis> <telerik:DateTimeContinuousAxis LabelFitMode="Rotate" LabelFormat="yyyy-MMM" GapLength="0.5"/> </telerik:RadCartesianChart.HorizontalAxis> <telerik:RadCartesianChart.VerticalAxis> <telerik:LinearAxis /> </telerik:RadCartesianChart.VerticalAxis> <telerik:RadCartesianChart.Series> <telerik:BarSeries CategoryBinding="Date" ValueBinding="Value" ItemsSource="{Binding Path=Series1}"> <telerik:BarSeries.PointTemplate> <DataTemplate> <Rectangle Fill="Blue" /> </DataTemplate> </telerik:BarSeries.PointTemplate> </telerik:BarSeries> <telerik:LineSeries CategoryBinding="Date" ValueBinding="Value" ItemsSource="{Binding Path=Series1}" Stroke="Red"> </telerik:LineSeries> </telerik:RadCartesianChart.Series> </telerik:RadCartesianChart> <StackPanel Grid.Row="1" Orientation="Horizontal"> <Label>MaximumTicks:</Label> <telerik:RadNumericUpDown IsEditable="True" Minimum="10" Maximum="50" Value="{Binding Path=MaximumTicks}"/> </StackPanel> </Grid></Window>Code Behind:
namespace BarDensity{ public class MyPoint { public DateTime Date { get; set; } public Double Value { get; set; } } public partial class MainWindow : Window { private int _MaximumTicks = 20; public List<MyPoint> Series1 { get; private set; } public int MaximumTicks { get { return _MaximumTicks; } set { if (_MaximumTicks != value) { _MaximumTicks = value; DateTimeContinuousAxis dateAxis = PropertyChart.HorizontalAxis as DateTimeContinuousAxis; if (dateAxis != null) dateAxis.MaximumTicks = _MaximumTicks; } } } public MainWindow() { Series1 = new List<MyPoint>(); DateTime startDate = new DateTime(2014, 1, 1); for (int i = 0; i < 1000; i++) Series1.Add(new MyPoint() { Date = startDate.AddMonths(i), Value = (Math.Sin(i / 100.0)) * 500 }); InitializeComponent(); DataContext = this; } }}