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

Stepline, null values and DateTime serie

1 Answer 53 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Ivano
Top achievements
Rank 1
Ivano asked on 20 May 2010, 11:44 AM

I'm trying to plot a “stepline” chart where AxisX is a DateTime and some points are nulls.
As I didn't find any specific series (I hope you'll address soon), I use LineSeriesDefinizion doubling data point (see code) but:
- null value are treated as 0 (wrong since 0 means 0 value while null means missing value)
- where first value is null, the control throws a NullReferenceException

        public MainWindow()

        {

            InitializeComponent();

            ConfigureChart();

        }

        private void ConfigureChart()

        {

            LineSeriesDefinition lineSeries = new LineSeriesDefinition();

            lineSeries.ShowItemLabels = false;

            lineSeries.ShowPointMarks = false;

            SeriesMapping actualMapping = new SeriesMapping();

            actualMapping.SeriesDefinition = lineSeries;

            actualMapping.LegendLabel = "Data";

            actualMapping.ItemMappings.Add(new ItemMapping("Day", DataPointMember.XValue));

            actualMapping.ItemMappings.Add(new ItemMapping("Value", DataPointMember.YValue));

            radChart.SeriesMappings.Add(actualMapping);

            radChart.DefaultView.ChartArea.AxisX.DefaultLabelFormat = "#VAL{dd-MM-yy}";

            radChart.DefaultView.ChartArea.AxisX.LabelRotationAngle = 45;

            radChart.DefaultView.ChartArea.AxisX.IsDateTime = true;

            radChart.ItemsSource = MyData.GetData();

        }

    }

    class MyData

    {

        public DateTime Day { get; set; }

        public double? Value { get; set; }

        public static List<MyData> GetData()

        {

            DateTime today = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);

            List<MyData> list = new List<MyData>();

            list.Add(new MyData() { Day = today, Value = null });

            list.Add(new MyData() { Day = today.AddDays(1), Value = 1 });

            list.Add(new MyData() { Day = today.AddDays(1), Value = 2 });

            list.Add(new MyData() { Day = today.AddDays(2), Value = 2 });

            list.Add(new MyData() { Day = today.AddDays(2), Value = 1.5 });

            list.Add(new MyData() { Day = today.AddDays(3), Value = 1.5 });

            return list;

        }

    }


Sincerely
Ivano

 

 

1 Answer, 1 is accepted

Sort by
0
Dwight
Telerik team
answered on 25 May 2010, 08:05 AM
Hi Ivano,

Yes, you  are right, null values should not be treated as 0. Currently the RadChart does not support null values and does not handle such scenarios correctly. This feature is in our TO-DO list, but I cannot provide any details on when it will be implemented.

Sincerely yours,
Joshua
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
Chart
Asked by
Ivano
Top achievements
Rank 1
Answers by
Dwight
Telerik team
Share this question
or