Hello,
I have a Gantt serie with some bars. I want to display a line between each bar which will have a label associated.
Example with the picture below:
The two blocks REQA and ATQA are connected (using the NextTasks property) and a line is displayed between them (using the ConnectingPen property).
Is there a way to add a label on this line, like for the blocks ?
Best regards.
Gantt chart: add a label on a connecting pen
Re: Gantt chart: add a label on a connecting pen
Hello,
I'm afraid this is not possible right now. However, it wouldn't be very difficult, for example, to have an array of Annotation tools to show the desired texts.
I'm afraid this is not possible right now. However, it wouldn't be very difficult, for example, to have an array of Annotation tools to show the desired texts.
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Re: Gantt chart: add a label on a connecting pen
Hi gcoray,
Yes, you can do that using Annotation tools set to a custom position in the OnAfterDraw event as in the example here:
Yes, you can do that using Annotation tools set to a custom position in the OnAfterDraw event as in the example here:
Code: Select all
public Form1()
{
InitializeComponent();
InitializeChart();
}
private Steema.TeeChart.Styles.Gantt gantt1;
private void InitializeChart()
{
tChart1.Aspect.View3D = false;
tChart1.Legend.Visible = false;
gantt1 = new Steema.TeeChart.Styles.Gantt(tChart1.Chart);
gantt1.Add(DateTime.Now, DateTime.Now.AddDays(2), 1, "task1");
gantt1.NextTasks[0]=gantt1.Add(DateTime.Now.AddDays(4), DateTime.Now.AddDays(5), 1, "task2");
tChart1.AfterDraw += new Steema.TeeChart.PaintChartEventHandler(tChart1_AfterDraw);
tChart1.Draw();
}
void tChart1_AfterDraw(object sender, Steema.TeeChart.Drawing.Graphics3D g)
{
for (int i = 0; i < gantt1.NextTasks.Count; i++)
{
int next = (int)gantt1.NextTasks[i];
if (next != -1)
{
Steema.TeeChart.Tools.Annotation annotation1 = new Steema.TeeChart.Tools.Annotation(tChart1.Chart);
annotation1.Shape.CustomPosition = true;
annotation1.Text = "Connecting line " + i.ToString();
SizeF textSize = g.MeasureString(annotation1.Shape.Font, annotation1.Text);
int x = gantt1.CalcXPosValue(gantt1.EndValues[i]) + (gantt1.CalcXPosValue(gantt1.StartValues[next]) - gantt1.CalcXPosValue(gantt1.EndValues[i])) / 2;
int y = gantt1.CalcYPos(i) - 30;
annotation1.Shape.Left = x - (int)textSize.Width / 2;
annotation1.Shape.Top = y;
}
}
}
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
Re: Gantt chart: add a label on a connecting pen
Hi,
Thank you very much ! I think this will be fine.
Best regards.
Thank you very much ! I think this will be fine.
Best regards.