Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
175
buggy Series behavior
posted

Hello Infragistics Engineers, 

I've attached a sample that demonstrates some buggy behavior when trying to add a Series to a chart using procedural code.  

Using the same function to add a series in the OnInitialized function produces different results than the same function used after the window is fully visible (which actually doesn't even work).

Maybe this is already fixed in a yet-to-be-released build?  Or there's a funny, specific way adding a Series should be done?

It would be nice to have in the docs a little more hand-holding/in-depth explanation on using the chart from procedural code.

XamChart is shaping up pretty nicely in most other areas.  Keep up the good work.

 Thanks,

Zac Morris 

 

Sample:

 XAML:

<igCA:XamChart x:Name="_chart" />

 

CS:

 using System;
using System.Collections.Generic;
using System.Windows;
using System.Windows.Input;
using System.Windows.Media;
using Infragistics.Windows.Chart;

namespace ChartSeriesBug
{
    public partial class Window1 : Window
    {
        public Window1()
        {
            InitializeComponent();

            _chart.MouseDoubleClick += _chart_MouseDoubleClick;
        }

        private void _chart_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            this.AddSeries(new Random().Next(), "After Initialized Procedural Series");
        }

        protected override void OnInitialized(EventArgs e)
        {
            base.OnInitialized(e);

            for (int i = 0; i < 2; i++)
            {
                this.AddSeries(i, "OnInitialized Procedural Series");
            }
        }

        private void AddSeries(int i, string seriesLabel)
        {
            Series series = new Series();

            series.ChartType = ChartType.Line;

            series.Label = seriesLabel;

            series.DataMapping = "Value=Watts; Label=Time";

            series.DataPointColor = DataPointColor.Auto;

            series.StrokeThickness = 2;

            series.Fill = Brushes.Red;

            series.Stroke = Brushes.Aqua;

            series.DataSource = new RandomReadings(i);

            _chart.Series.Add(series);
        }
    }

    public class RandomReadings : List<PowerReading>
    {
        public RandomReadings(int offset)
        {
            for (int i = 0; i < 10; i++)
            {
                this.Add(new PowerReading
                {
                    Time = new DateTime(2007, 12, 1, i, 0, 0),
                    Watts = i + offset
                }
            )
                ;
            }
        }
    }

    public class PowerReading
    {
        public DateTime Time { get; set; }

        public double Watts { get; set; }
    }
}