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
65
GanttChart - I want series in specific order
posted

Hello,

I am looking for help with WinChart I use with VS2005 in C#.

The type of chart I use is a GanttChart. I created DataTable which as a first column gets series name. Everything works fine, but I need one improvement in my app, because now chart displays the data grouped in series, but I cannot see any rule in order of displaying series.

So users can see one time 'critical' series in the upper part of chart, another time at the bottom, and they want to see it in specific order: for example - first - critical, then 'normal', then 'can wait'.

Is there any way I can specify the order of displaying series?

And if there is no way to do it, also please tell me about that.

Thank you in advance for any ideas,
Agnieszka

  • 27093
    posted

    Hello Agniezska,

    Usually the GanttChart is used for visualizing time spans. Here is a sample GantChart:

    As you see the X axis starts with the earliest DateTime value and this is what first came ot my mind as ugrent or critical. Tell me if you have something else in mind.

    Sincerely,

    Petar Monov

    Developer Support Engineer,

    Infragistics, Inc

     

  • 7305
    Verified Answer
    posted

    The serieses should appear in the order of being added. Here is a code snippet that you can test.

            GanttSeries series1 = null;
            GanttSeries series2 = null;
            GanttSeries series3 = null;

            private void Form1_Load(object sender, EventArgs e)
            {
                this.ultraChart1.ChartType
                    = Infragistics.UltraChart.Shared.Styles.ChartType.GanttChart;
                this.ultraChart1.Axis.Y.Labels.SeriesLabels.Format = AxisSeriesLabelFormat.None;

               
                // ZOOM X axis
                this.ultraChart1.Axis.X.ScrollScale.Visible = true;

                ultraChart1.GanttChart.Columns.SeriesLabelsColumnIndex = 0;
                ultraChart1.GanttChart.Columns.ItemLabelsColumnIndex = 1;
                // Start time of the planned task
                ultraChart1.GanttChart.Columns.StartTimeColumnIndex = 2;
                // End time of the planned task
                ultraChart1.GanttChart.Columns.EndTimeColumnIndex = 3;
                ultraChart1.GanttChart.Columns.IDColumnIndex = 4;
                // Link a task to another task using column index
                ultraChart1.GanttChart.Columns.LinkToColumnIndex = 5;
                ultraChart1.GanttChart.Columns.PercentCompleteColumnIndex = 6;
                ultraChart1.GanttChart.Columns.OwnerColumnIndex = 7;

                GanttDataSource ganttDataSource = new GanttDataSource();

                series1 = GetSeries1();
                ganttDataSource.Series.Add(series1);
                series2 = GetSeries2();
                ganttDataSource.Series.Add(series2);
                series3 = GetSeries3();
                ganttDataSource.Series.Add(series3);


                this.ultraChart1.DataSource = ganttDataSource;
                this.ultraChart1.Data.DataBind();
            }

            public GanttSeries GetSeries1()
            {
                GanttSeries series1 = new GanttSeries("Series 1");
                GanttItem goal1 = series1.Items.Add("Other");
                goal1.Times.Add(DateTime.Parse("04/11/2006 11:00 PM"), DateTime.Parse("04/15/2006 08:00 PM"));
                goal1.Times.Add(DateTime.Parse("04/16/2006 11:00 PM"), DateTime.Parse("04/18/2006 08:00 PM"));
                goal1.Times.Add(DateTime.Parse("04/18/2006 11:00 PM"), DateTime.Parse("04/21/2006 08:00 PM"));
                goal1.Times.Add(DateTime.Parse("04/21/2006 11:00 PM"), DateTime.Parse("04/25/2006 08:00 PM"));
                goal1.Times.Add(DateTime.Parse("04/27/2006 11:00 PM"), DateTime.Parse("04/30/2006 08:00 PM"));
                goal1.Times.Add(DateTime.Parse("04/30/2006 11:00 PM"), DateTime.Parse("05/03/2006 08:00 PM"));
                goal1.Times.Add(DateTime.Parse("05/04/2006 11:00 PM"), DateTime.Parse("05/07/2006 08:00 PM"));
                return series1;
            }

            public GanttSeries GetSeries2()
            {
                GanttSeries series2 = new GanttSeries("Series 2");
                GanttItem goal2 = series2.Items.Add("Normal");
                goal2.Times.Add(DateTime.Parse("04/11/2006 11:00 PM"), DateTime.Parse("04/12/2006 08:00 PM"));
                goal2.Times.Add(DateTime.Parse("04/13/2006 11:00 PM"), DateTime.Parse("04/15/2006 08:00 PM"));
                goal2.Times.Add(DateTime.Parse("04/15/2006 11:00 PM"), DateTime.Parse("04/18/2006 08:00 PM"));
                goal2.Times.Add(DateTime.Parse("04/19/2006 11:00 PM"), DateTime.Parse("04/20/2006 08:00 PM"));
                goal2.Times.Add(DateTime.Parse("04/21/2006 11:00 PM"), DateTime.Parse("04/25/2006 08:00 PM"));
                goal2.Times.Add(DateTime.Parse("04/25/2006 11:00 PM"), DateTime.Parse("04/27/2006 08:00 PM"));
                goal2.Times.Add(DateTime.Parse("04/28/2006 11:00 PM"), DateTime.Parse("05/02/2006 08:00 PM"));
                return series2;
            }

            public GanttSeries GetSeries3()
            {
                GanttSeries series3 = new GanttSeries("Series 3");
                GanttItem goal3 = series3.Items.Add("Critical");
                goal3.Times.Add(DateTime.Parse("04/11/2006 11:00 PM"), DateTime.Parse("04/13/2006 08:00 PM"));
                goal3.Times.Add(DateTime.Parse("04/13/2006 11:00 PM"), DateTime.Parse("04/15/2006 08:00 PM"));
                goal3.Times.Add(DateTime.Parse("04/16/2006 11:00 PM"), DateTime.Parse("04/18/2006 08:00 PM"));
                goal3.Times.Add(DateTime.Parse("04/19/2006 11:00 PM"), DateTime.Parse("04/21/2006 08:00 PM"));
                goal3.Times.Add(DateTime.Parse("04/22/2006 11:00 PM"), DateTime.Parse("04/25/2006 08:00 PM"));
                goal3.Times.Add(DateTime.Parse("04/26/2006 11:00 PM"), DateTime.Parse("04/27/2006 08:00 PM"));
                goal3.Times.Add(DateTime.Parse("04/28/2006 11:00 PM"), DateTime.Parse("05/01/2006 08:00 PM"));
                return series3;
            }