This is a migrated thread and some comments may be shown as answers.

Setting DateTimeContinuousAxis.Maximum property results in line or area series being displayed incorrectly.

1 Answer 63 Views
ChartView
This is a migrated thread and some comments may be shown as answers.
John
Top achievements
Rank 1
John asked on 08 Nov 2011, 04:23 PM

Hi,

I'm using the Q3 2011 beta, V1020. When setting DateTimeContinuousAxis.Maximum line or area series are displayed incorrectly, as shown in the attached screenshots.

With the line series it appears that a line is drawn up to the top left hand corner of the screen. This look very similar to the problem described in the forum posting "Line series fails to handle nulls and NaN", although in this case there are no null values.

Do you know if there is a workaround for this or if it is scheduled to be fixed? I've pasted the code below

Thanks,

John.

C#:

 

    public class Measurement
    {
        public DateTime StartDateTime { get; set; }
        public double Value { get; set; }
    }

    public partial class MainPage : UserControl
    {
        public MainPage()
        {
            InitializeComponent();

            List<Measurement> measurements = new List<Measurement>();
            DateTime startDateTime = new DateTime(2010, 1, 1);
            DateTime endDateTime = new DateTime(2010, 1, 2);
            Measurement currentMeasurement = null;
            Random random = new Random();

            while (startDateTime < endDateTime)
            {
                currentMeasurement = new Measurement()
                                         {
                                             StartDateTime = startDateTime,
                                             Value = 2 + random.Next(-2, 2)
                                         };

                measurements.Add(currentMeasurement);
                startDateTime = startDateTime.AddHours(1);
            }

            DateTimeContinuousAxis horizontalAxis = new DateTimeContinuousAxis()
            {
                LabelFitMode = AxisLabelFitMode.MultiLine,
                LabelFormat = "HH:mm"
            };

            _chart.HorizontalAxis = horizontalAxis;
            _chart.VerticalAxis = new LinearAxis();

            LineSeries categoricalSeries = new LineSeries();

            categoricalSeries.ValueBinding = new PropertyNameDataPointBinding()
            {
                PropertyName = "Value"
            };

            categoricalSeries.CategoryBinding = new PropertyNameDataPointBinding()
            {
                PropertyName = "StartDateTime"
            };

            categoricalSeries.ItemsSource = measurements;
            _chart.Series.Add(categoricalSeries);
            horizontalAxis.Maximum = new DateTime(2010, 1, 1, 22, 0, 0); // Remove this line to display series correctly.
        }
    }


XAML:

<UserControl x:Class="TimeBarTest.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:telerik="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Chart" xmlns:Controls="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.DataVisualization" xmlns:TimeBar="clr-namespace:Telerik.Windows.Controls.TimeBar;assembly=Telerik.Windows.Controls.DataVisualization" mc:Ignorable="d"
    d:DesignHeight="300" d:DesignWidth="400">

    <Grid x:Name="LayoutRoot" Background="White">
        <StackPanel>
            <telerik:RadCartesianChart x:Name="_chart" Height="800" HorizontalAlignment="Stretch" Margin="0,10,0,0" Background="Transparent"
          BorderBrush="{x:Null}" BorderThickness="0"
                            Palette="Metro"/>
        </StackPanel>
    </Grid>
</UserControl>

1 Answer, 1 is accepted

Sort by
0
Accepted
Giuseppe
Telerik team
answered on 10 Nov 2011, 12:27 PM
Hello John,

Thank you for contacting us.

Indeed we are aware of this rendering glitch that occurs if you try to restrict the visible Axis.Maximum property to a value that is less than the actual maximum value coming from the series data (in this case you have set 22h as the maximum but your last measurement is for 23h).

As a workaround at the moment we would suggest you to set the Axis.Maximum to a value that is equal or greater than the actual data maximum e.g.:
horizontalAxis.Maximum = new DateTime(2010, 1, 1, 23, 0, 0);

We have discussed the problem with our devteam and it seems unlikely that we will be able to incorporate the permanent fix for the Q3 release (scheduled for next week) but we will certainly address this problem with high priority for one of the first weekly internal builds after that (you can track the resolution progress here).

Hope this helps.


Best wishes,
Giuseppe
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Tags
ChartView
Asked by
John
Top achievements
Rank 1
Answers by
Giuseppe
Telerik team
Share this question
or