TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
-
NojaPower
- Newbie
- Posts: 6
- Joined: Fri Feb 22, 2008 12:00 am
Post
by NojaPower » Thu Sep 24, 2009 4:46 am
Version: 3.5.3498.27368
OS: Windows XP
Hi,
I am trying to create an annotation with a callout in code but are having trouble getting it to display.
I am after a annotation with no border, a gradient fill, and a shadow. The callout is to be red with no pointer. I have tried several variantions on the following code with no success (I get an white annotation with no callout or gradient fill).
Code: Select all
Steema.TeeChart.Tools.Annotation backgroundCurveLabel = new Steema.TeeChart.Tools.Annotation();
backgroundCurveLabel.Active = true;
backgroundCurveLabel.Text = tccManager.GetTCCName(backgroundCurveID);
backgroundCurveLabel.AutoSize = true;
backgroundCurveLabel.Callout.Visible = true;
backgroundCurveLabel.Callout.Style = PointerStyles.Nothing;
backgroundCurveLabel.Callout.XPosition = MainSeries.CalcXPos(this.MainSeries.Count / 2);
backgroundCurveLabel.Callout.YPosition = MainSeries.CalcYPos(this.MainSeries.Count / 2);
backgroundCurveLabel.Callout.Pen.Visible = true;
backgroundCurveLabel.Callout.Pen.Color = Color.Red;
backgroundCurveLabel.Callout.Pen.Width = 3;
backgroundCurveLabel.Left = this.MainSeries.CalcXPos(this.MainSeries.Count / 2) + 20;
backgroundCurveLabel.Top = this.MainSeries.CalcYPos(this.MainSeries.Count / 2) - 20;
backgroundCurveLabel.Shape.Brush.Gradient.StartColor = Color.Cornsilk;
backgroundCurveLabel.Shape.Brush.Gradient.Visible = true;
backgroundCurveLabel.Shape.Pen.Visible = false;
parentChart.Tools.Add(backgroundCurveLabel);
Also, i have tried using the designer to create the code and whilst being displayed correctly in the design view, the property changes for the annotation and the callout are not being serialized, and not displayed at runtime.
TIA,
NojaPower
-
Yeray
- Site Admin
- Posts: 9614
- Joined: Tue Dec 05, 2006 12:00 am
- Location: Girona, Catalonia
-
Contact:
Post
by Yeray » Thu Sep 24, 2009 10:37 am
Hi NojaPower,
The following code seems to achieve what you want here:
Code: Select all
public Form1()
{
InitializeComponent();
InitializeChart();
}
Steema.TeeChart.Styles.FastLine fast1;
Steema.TeeChart.Tools.Annotation annotation1;
private void InitializeChart()
{
chartController1.Chart = tChart1;
tChart1.Aspect.View3D = false;
fast1 = new Steema.TeeChart.Styles.FastLine(tChart1.Chart);
fast1.FillSampleValues();
annotation1 = new Steema.TeeChart.Tools.Annotation(tChart1.Chart);
annotation1.Text = "annotation1";
annotation1.Callout.Style = Steema.TeeChart.Styles.PointerStyles.Nothing;
annotation1.Callout.Arrow.Visible = true;
annotation1.Callout.Arrow.Color = Color.Red;
annotation1.Shape.Brush.Gradient.StartColor = Color.Cornsilk;
annotation1.Shape.Brush.Gradient.Visible = true;
annotation1.Shape.Pen.Visible = false;
tChart1.AfterDraw += new Steema.TeeChart.PaintChartEventHandler(tChart1_AfterDraw);
tChart1.Draw();
}
void tChart1_AfterDraw(object sender, Steema.TeeChart.Drawing.Graphics3D g)
{
annotation1.Callout.XPosition = fast1.CalcXPos(fast1.Count / 2);
annotation1.Callout.YPosition = fast1.CalcYPos(fast1.Count / 2);
annotation1.Left = fast1.CalcXPos(fast1.Count / 2) + 20;
annotation1.Top = fast1.CalcYPos(fast1.Count / 2) - 20;
}
-
NojaPower
- Newbie
- Posts: 6
- Joined: Fri Feb 22, 2008 12:00 am
Post
by NojaPower » Thu Sep 24, 2009 9:55 pm
Hi Yeray,
Why do you need to re-initialise the values after each draw of the chart? Why can it not be performed during the initialise component.
Cheers,
NojaPower
-
Yeray
- Site Admin
- Posts: 9614
- Joined: Tue Dec 05, 2006 12:00 am
- Location: Girona, Catalonia
-
Contact:
Post
by Yeray » Fri Sep 25, 2009 10:29 am
Hi NojaPower,
Excuse me, only the position should be set each time in this example to allow chart scroll/zoom.
I've now corrected the code.
-
NojaPower
- Newbie
- Posts: 6
- Joined: Fri Feb 22, 2008 12:00 am
Post
by NojaPower » Tue Sep 29, 2009 12:06 am
Hi Yeray,
The key line i take it is:
annotation1.Callout.Arrow.Visible = true;
Without this the callout is not drawn. For mind, it is a little misleading - if you did not want to have an arrow visible you would not set this value to true.
Cheers,
NojaPower