Displaying specific range of data

Aug 31, 2010 at 9:47 AM

Hi, i am following sample code described in http://msdn.microsoft.com/en-us/magazine/ff714591.aspx. I created data range from year 1600 to 2010. Now i want to display only 2010 data when loading first time. When user scrolls towards other dates range, then can view the data. Requirement is that it should not display all data at first time loading. I am not using ChtPlotter.Viewport.FitToView() but seems by default it will show all data. Even I dont want to map x-y axis for range of dates which i dont want to view. If i bind such huge data at first time (creating 10 line graphs), it takes very long time.

Thanks in advance.

Aug 31, 2010 at 11:31 AM
  Doesn't using
plotter.Visible = new DataRect(minX, minY, widthX, WidthY);
for the initial range not solve the problem?
See http://dynamicdatadisplay.codeplex.com/Thread/View.aspx?ThreadId=225274
David Roh
Sep 1, 2010 at 2:39 AM

I am using chart plotter with HorizontalDateTimeAxis and VerticalIntegerAxis. buginfo.txt is having data from 1900 to 2011. When chtplotter loads, it should display only 2010-2011 data. User can view rest data when scrolls.

 public partial class Window1 : Window
    {
        public Window1()
        {
            InitializeComponent();
        }

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            DisplayBugInfo();            
        }

        private void DisplayBugInfo()
        {
            List<BugInfo> bugInfoList = LoadBugInfo("..\\..\\BugInfo.txt");
            DateTime[] dates = new DateTime[bugInfoList.Count];
            int[] numberOpen = new int[bugInfoList.Count];
            int[] numberClosed = new int[bugInfoList.Count];
            int[] numberPerformanceRating = new int[bugInfoList.Count];
            int[] numberTransitionInterval = new int[bugInfoList.Count];
            int[] numberSteps = new int[bugInfoList.Count];
            int[] numberIntegration = new int[bugInfoList.Count];
            int[] numberTestingFail = new int[bugInfoList.Count];
            int[] numberTestingSuccess = new int[bugInfoList.Count];
            int[] numberTestingPhase = new int[bugInfoList.Count];

            for (int i = 0; i < bugInfoList.Count; i++)
            {
                dates[i] = bugInfoList[i].date;

                numberOpen[i] = bugInfoList[i].numberopen;
                numberClosed[i] = bugInfoList[i].numberclosed;
                numberPerformanceRating[i] = bugInfoList[i].PerformanceRating;
                numberTransitionInterval[i] = bugInfoList[i].TransitionInterval;
                numberSteps[i] = bugInfoList[i].Steps;
                numberIntegration[i] = bugInfoList[i].Integration;
                numberTestingFail[i] = bugInfoList[i].TestingFail;
                numberTestingPhase[i] = bugInfoList[i].TestingPhase;
                numberTestingSuccess[i] = bugInfoList[i].TestingSuccess;
            }


            //i dont want to map all data initially??
            var datesDataSource = new EnumerableDataSource<DateTime>(dates);
            datesDataSource.SetXMapping(x => DateAxis.ConvertToDouble(x));

            var numberOpenDataSource = new EnumerableDataSource<int>(numberOpen);
            numberOpenDataSource.SetYMapping(y => y);

            var numberClosedDataSource = new EnumerableDataSource<int>(numberClosed);
            numberClosedDataSource.SetYMapping(y => y);

            var numberRatingDataSource = new EnumerableDataSource<int>(numberPerformanceRating);
            numberRatingDataSource.SetYMapping(y => y);

            var numberIntervalDataSource = new EnumerableDataSource<int>(numberTransitionInterval);
            numberIntervalDataSource.SetYMapping(y => y);

            var numberStepsDataSource = new EnumerableDataSource<int>(numberSteps);
            numberStepsDataSource.SetYMapping(y => y);

            var numberIntegrationDataSource = new EnumerableDataSource<int>(numberIntegration);
            numberIntegrationDataSource.SetYMapping(y => y);

            var numberTestFailDataSource = new EnumerableDataSource<int>(numberTestingFail);
            numberTestFailDataSource.SetYMapping(y => y);

            var numberTestPhaseDataSource = new EnumerableDataSource<int>(numberTestingPhase);
            numberTestPhaseDataSource.SetYMapping(y => y);

            var numberTestSuccessDataSource = new EnumerableDataSource<int>(numberTestingSuccess);
            numberTestSuccessDataSource.SetYMapping(y => y);            

            CompositeDataSource compositedatasource1 = new CompositeDataSource(datesDataSource, numberOpenDataSource);
            CompositeDataSource compositedatasource2 = new CompositeDataSource(datesDataSource, numberClosedDataSource);
            CompositeDataSource compositedatasource3 = new CompositeDataSource(datesDataSource, numberRatingDataSource);
            CompositeDataSource compositedatasource4 = new CompositeDataSource(datesDataSource, numberIntervalDataSource);
            CompositeDataSource compositedatasource5 = new CompositeDataSource(datesDataSource, numberStepsDataSource);
            CompositeDataSource compositedatasource6 = new CompositeDataSource(datesDataSource, numberIntegrationDataSource);
            CompositeDataSource compositedatasource7 = new CompositeDataSource(datesDataSource, numberTestFailDataSource);
            CompositeDataSource compositedatasource8 = new CompositeDataSource(datesDataSource, numberTestPhaseDataSource);
            CompositeDataSource compositedatasource9 = new CompositeDataSource(datesDataSource, numberTestSuccessDataSource);

            ChtPlotter.AddLineGraph(compositedatasource1,
                                    new Pen(Brushes.Blue, 2),
                                    new CirclePointMarker { Size = 10.0, Fill = Brushes.Red },
                                    new PenDescription("New Bugs Open"));

            ChtPlotter.AddLineGraph(compositedatasource2,
                                    new Pen(Brushes.Green, 2),
                                    //new TrianglePointMarker { Size = 10.0, Fill = Brushes.GreenYellow, Pen = new Pen(Brushes.Black, 2.0) },
                                     new CirclePointMarker { Size = 10.0, Fill = Brushes.GreenYellow },
                                    new PenDescription("Number Bugs Closed"));

            ChtPlotter.AddLineGraph(compositedatasource3,
                                    new Pen(Brushes.MediumPurple, 2),
                                    //new TrianglePointMarker { Size = 10.0, Fill = Brushes.Magenta, Pen = new Pen(Brushes.Black, 2.0) },
                                    new CirclePointMarker { Size = 10.0, Fill = Brushes.Magenta },
                                    new PenDescription("Performance Rating"));

            ChtPlotter.AddLineGraph(compositedatasource4,
                                    new Pen(Brushes.Brown, 2),
                                    new CirclePointMarker { Size = 10.0, Fill = Brushes.Red },
                                    new PenDescription("Number of Transition Interval"));

            ChtPlotter.AddLineGraph(compositedatasource5,
                                    new Pen(Brushes.Chocolate, 2),
                                    //new TrianglePointMarker { Size = 10.0, Fill = Brushes.LightPink, Pen = new Pen(Brushes.Black, 2.0) },
                                    new CirclePointMarker { Size = 10.0, Fill = Brushes.LightPink },
                                    new PenDescription("Number of Steps"));

            ChtPlotter.AddLineGraph(compositedatasource6,
                                    new Pen(Brushes.DarkBlue, 2),
                                    new CirclePointMarker { Size = 10.0, Fill = Brushes.Red },
                                    new PenDescription("Number of Integration"));

            ChtPlotter.AddLineGraph(compositedatasource7,
                                    new Pen(Brushes.DarkMagenta, 2),
                                    new CirclePointMarker { Size = 10.0, Fill = Brushes.Red },
                                    new PenDescription("Number of Test Failed"));

            ChtPlotter.AddLineGraph(compositedatasource8,
                                    new Pen(Brushes.Orange, 2),
                                    //new TrianglePointMarker { Size = 10.0, Fill = Brushes.Gray, Pen = new Pen(Brushes.Black, 2.0) },
                                     new CirclePointMarker { Size = 10.0, Fill = Brushes.Gray },
                                    new PenDescription("Number of Testing Phase"));

            ChtPlotter.AddLineGraph(compositedatasource9,
                                    new Pen(Brushes.DeepPink, 2),
                                    //new TrianglePointMarker { Size = 10.0, Fill = Brushes.FloralWhite, Pen = new Pen(Brushes.Black, 2.0) },
                                     new CirclePointMarker { Size = 10.0, Fill = Brushes.FloralWhite },
                                    new PenDescription("Number of Test Succeed"));

            // want to view data from 2000 to 2010. when user scrolls, then can view other data.
            //ChtPlotter.Viewport.FitToView();            
            //ChtPlotter.Visible = new DataRect(2000, 0, 2010, 1000);
        }   

        private static List<BugInfo> LoadBugInfo(string filename)
        {
            var result = new List<BugInfo>();
            FileStream fs = new FileStream(filename, FileMode.Open);
            StreamReader sr = new StreamReader(fs);
            string line = "";
            while ((line = sr.ReadLine()) != null)
            {
                try
                {
                    string[] pieces = line.Split(':');
                    DateTime dt = DateTime.Parse(pieces[0]);
                    int numopen = int.Parse(pieces[1]);
                    int numclosed = int.Parse(pieces[2]);
                    int numrating = int.Parse(pieces[3]);
                    int numinterval = int.Parse(pieces[4]);
                    int numsteps = int.Parse(pieces[5]);
                    int numintegration = int.Parse(pieces[6]);
                    int numtestfail = int.Parse(pieces[7]);
                    int numtestphase = int.Parse(pieces[8]);
                    int numtestsuccess = int.Parse(pieces[9]);
                    BugInfo bi = new BugInfo(dt, numopen, numclosed, numrating, numinterval, numsteps,
                                            numintegration, numtestfail, numtestphase, numtestsuccess);
                    result.Add(bi);
                }
                catch(Exception ex)
                { throw; }
            }
            sr.Close();
            fs.Close();
            return result;
        }     
    }
    
    public class BugInfo
    {
        public DateTime date;
        public int numberopen;
        public int numberclosed;
        public int PerformanceRating;
        public int TransitionInterval;
        public int Steps;
        public int Integration;
        public int TestingFail;
        public int TestingPhase;
        public int TestingSuccess;

        public BugInfo(DateTime date, int numberOpen, int numberClosed, int rating, int interval, 
                        int steps, int integration, int testfail, int testphase, int testsuccess)
        {
            this.date = date;
            this.numberopen = numberOpen;
            this.numberclosed = numberClosed;
            this.PerformanceRating = rating;
            this.TransitionInterval = interval;
            this.Steps = steps;
            this.Integration = integration;
            this.TestingFail = testfail;
            this.TestingPhase = testphase;
            this.TestingSuccess = testsuccess;
        }
    }


            this.Steps = steps;
            this.Integration = integration;
            this.TestingFail = testfail;
            this.TestingPhase = testphase;
            this.TestingSuccess = testsuccess;
        }