Page 1 of 1
Gantt color does not change..
Posted: Mon Jul 14, 2008 7:32 am
by 9788246
Hi..
I use "TeeChart 2.0.3033.18431" in a web application (Steema.TeeChart.Chart). The Datasource is defined for a gannt (X,Y,start,end,nexttask,color). Everything is ok except the color of the gantts. they are always beeing shown in standard colors (~orange & ~red). But wenn I use the same code in a normal windows form (with Steema.TeeChart.TChart) then works everything normal..
Do you have any idea?Thanks...
Posted: Mon Jul 14, 2008 8:00 am
by narcis
Hi MU,
This works fine for me here using this code:
Code: Select all
Steema.TeeChart.Styles.Gantt gantt1 = new Steema.TeeChart.Styles.Gantt(WebChart1.Chart);
gantt1.Add(DateTime.Parse("14/07/2008"), DateTime.Parse("18/07/2008"), 0, System.Drawing.Color.Yellow);
gantt1.Add(DateTime.Parse("13/07/2008"), DateTime.Parse("15/07/2008"), 1, System.Drawing.Color.Red);
gantt1.Add(DateTime.Parse("16/07/2008"), DateTime.Parse("19/07/2008"), 2, System.Drawing.Color.Blue);
gantt1.Add(DateTime.Parse("12/07/2008"), DateTime.Parse("16/07/2008"), 3, System.Drawing.Color.Green);
gantt1.Add(DateTime.Parse("13/07/2008"), DateTime.Parse("17/07/2008"), 4, System.Drawing.Color.White);
Could you please modify it or send a simple example project we can run "as-is" to reproduce the problem here? You could reproduce datasource as in the example Christopher Ireland posted
here.
You can either post your files at news://
www.steema.net/steema.public.attachments newsgroup or at our
upload page.
Thanks in advance.
Posted: Mon Jul 14, 2008 8:44 am
by 9788246
Hi Narcis...
I used the ShowSeries.aspx...
Code: Select all
chart= new Chart();
/*
//Datatable
DataTable table = new DataTable();
table.Columns.Add("Label", typeof(string));
table.Columns.Add("Y", typeof(int));
table.Columns.Add("Next", typeof(int));
table.Columns.Add("Start", typeof(DateTime));
table.Columns.Add("End", typeof(DateTime));
table.Columns.Add("ColorTask", typeof(Color));
*/
//Add Series to Chart
switch (Request.QueryString["seriestype"])
{
case "Line": chart.Series.Add(new Steema.TeeChart.Styles.Line());
chart.Series.Add(new Steema.TeeChart.Styles.Line()); break;
case "Bar": chart.Series.Add(new Steema.TeeChart.Styles.Bar()); break;
case "HorizBar": chart.Series.Add(new Steema.TeeChart.Styles.HorizBar()); break;
case "Area": chart.Series.Add(new Steema.TeeChart.Styles.Area()); break;
case "Point": chart.Series.Add(new Steema.TeeChart.Styles.Points()); break;
case "Surface": chart.Series.Add(new Steema.TeeChart.Styles.Surface()); break;
case "Gantt":
if (Session["ProjectTable"] != null)//datasource
{
Gantt gannt = new Gantt();
DataTable table = (DataTable)Session["ProjectTable"];
gannt.ColorEach = false;
gannt.DataSource = table;
gannt.EndValues.DataMember = "End";
gannt.EndValues.DateTime = true;
gannt.LabelMember = "Label";
gannt.NextTasks.DataMember = "Next";
gannt.StartValues.DataMember = "Start";
gannt.StartValues.DateTime = true;
gannt.XValues.DataMember = "Start";
gannt.XValues.DateTime = true;
gannt.YValues.DataMember = "Y";
gannt.ColorMember = "ColorTask";
gannt.Title = "Title...";
gannt.LinePen.Width = 2;
gannt.LinePen.Color = Color.Green;
gannt.CheckDataSource();
chart.Series.Add(gannt);
}
}
As I said everything is ok except the color (in asp.net).
it works windows for with Steema.Teechart.TChart.
Posted: Mon Jul 14, 2008 9:09 am
by narcis
Hi MU,
Have you tried setting ColorEach property to true instead of false as in the code snippet you posted?
Code below works fine for me here:
Code: Select all
protected void Page_Load(object sender, EventArgs e)
{
DataTable table = new DataTable();
table.Columns.Add("Label", typeof(string));
table.Columns.Add("Y", typeof(int));
table.Columns.Add("Next", typeof(int));
table.Columns.Add("Start", typeof(DateTime));
table.Columns.Add("End", typeof(DateTime));
table.Columns.Add("ColorTask", typeof(Color));
DataRow dataRow;
dataRow = table.NewRow();
dataRow[0] = "Project 1";
dataRow[1] = 1;
dataRow[2] = 2;
dataRow[3] = DateTime.Parse("14/07/2008");
dataRow[4] = DateTime.Parse("18/07/2008"); ;
dataRow[5] = System.Drawing.Color.Red;
table.Rows.Add(dataRow);
dataRow = table.NewRow();
dataRow[0] = "Project 2";
dataRow[1] = 2;
dataRow[2] = 3;
dataRow[3] = DateTime.Parse("16/07/2008");
dataRow[4] = DateTime.Parse("20/07/2008"); ;
dataRow[5] = System.Drawing.Color.Blue;
table.Rows.Add(dataRow);
dataRow = table.NewRow();
dataRow[0] = "Project 3";
dataRow[1] = 3;
dataRow[2] = -1;
dataRow[3] = DateTime.Parse("23/07/2008");
dataRow[4] = DateTime.Parse("30/07/2008"); ;
dataRow[5] = System.Drawing.Color.Yellow;
table.Rows.Add(dataRow);
dataRow = table.NewRow();
dataRow[0] = "Project 4";
dataRow[1] = 4;
dataRow[2] = -1;
dataRow[3] = DateTime.Parse("25/07/2008");
dataRow[4] = DateTime.Parse("28/07/2008"); ;
dataRow[5] = System.Drawing.Color.Green;
table.Rows.Add(dataRow);
Steema.TeeChart.Styles.Gantt gantt = new Steema.TeeChart.Styles.Gantt(WebChart1.Chart);
//gantt.ColorEach = false;
gantt.DataSource = table;
gantt.EndValues.DataMember = "End";
gantt.EndValues.DateTime = true;
gantt.LabelMember = "Label";
gantt.NextTasks.DataMember = "Next";
gantt.StartValues.DataMember = "Start";
gantt.StartValues.DateTime = true;
gantt.XValues.DataMember = "Start";
gantt.XValues.DateTime = true;
gantt.YValues.DataMember = "Y";
gantt.ColorMember = "ColorTask";
gantt.Title = "Title...";
gantt.LinePen.Width = 2;
gantt.LinePen.Color = Color.Green;
gantt.CheckDataSource();
}
Posted: Mon Jul 14, 2008 12:41 pm
by 9788246
The problem is probably something different. Actually my code and your code are working. but wenn I use the Seesion in order to send the datatable to the Series.aspx page, the colors are not received. I dont know why (The are empty)
Thank you..
Posted: Mon Jul 14, 2008 12:47 pm
by narcis
Hi MU,
In that case you can try storing and retrieving session variables as in the Zooming example at the
live ASP.NET demo.
If this doesn't help please send us a simple example project we can run "as-is" to reproduce the problem here.
Thanks in advance.
Posted: Mon Jul 14, 2008 1:48 pm
by narcis
Hi MU.
As an upgrade, code below works fine for me here. Could you please check if it works fine at your end?
Code: Select all
protected void Page_Load(object sender, EventArgs e)
{
if (Session["ProjectTable"] == null)
{
DataTable table = new DataTable();
table.Columns.Add("Label", typeof(string));
table.Columns.Add("Y", typeof(int));
table.Columns.Add("Next", typeof(int));
table.Columns.Add("Start", typeof(DateTime));
table.Columns.Add("End", typeof(DateTime));
table.Columns.Add("ColorTask", typeof(Color));
DataRow dataRow;
dataRow = table.NewRow();
dataRow[0] = "Project 1";
dataRow[1] = 1;
dataRow[2] = 2;
dataRow[3] = DateTime.Parse("14/07/2008");
dataRow[4] = DateTime.Parse("18/07/2008"); ;
dataRow[5] = System.Drawing.Color.Red;
table.Rows.Add(dataRow);
dataRow = table.NewRow();
dataRow[0] = "Project 2";
dataRow[1] = 2;
dataRow[2] = 3;
dataRow[3] = DateTime.Parse("16/07/2008");
dataRow[4] = DateTime.Parse("20/07/2008"); ;
dataRow[5] = System.Drawing.Color.Blue;
table.Rows.Add(dataRow);
dataRow = table.NewRow();
dataRow[0] = "Project 3";
dataRow[1] = 3;
dataRow[2] = -1;
dataRow[3] = DateTime.Parse("23/07/2008");
dataRow[4] = DateTime.Parse("30/07/2008"); ;
dataRow[5] = System.Drawing.Color.Yellow;
table.Rows.Add(dataRow);
dataRow = table.NewRow();
dataRow[0] = "Project 4";
dataRow[1] = 4;
dataRow[2] = -1;
dataRow[3] = DateTime.Parse("25/07/2008");
dataRow[4] = DateTime.Parse("28/07/2008"); ;
dataRow[5] = System.Drawing.Color.Green;
table.Rows.Add(dataRow);
Session.Add("ProjectTable", table);
}
Steema.TeeChart.Styles.Gantt gantt = new Steema.TeeChart.Styles.Gantt(WebChart1.Chart);
//gantt.ColorEach = false;
DataTable sessionTable = (DataTable)Session["ProjectTable"];
gantt.DataSource = sessionTable;
gantt.EndValues.DataMember = "End";
gantt.EndValues.DateTime = true;
gantt.LabelMember = "Label";
gantt.NextTasks.DataMember = "Next";
gantt.StartValues.DataMember = "Start";
gantt.StartValues.DateTime = true;
gantt.XValues.DataMember = "Start";
gantt.XValues.DateTime = true;
gantt.YValues.DataMember = "Y";
gantt.ColorMember = "ColorTask";
gantt.Title = "Title...";
gantt.LinePen.Width = 2;
gantt.LinePen.Color = Color.Green;
gantt.CheckDataSource();
}