Showing Image in Annotation

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
mweaver
Newbie
Newbie
Posts: 10
Joined: Tue Apr 08, 2003 4:00 am

Showing Image in Annotation

Post by mweaver » Fri Nov 21, 2003 7:07 pm

Suppose you want to add a company logo to a chart template, so every chart
has the logo in the bottom right corner (or whereever).

I have tried using a Tools.Annotation to do this, but there are a few
problems.

1) the image does not save/restore with the template. if you create an
annotation and set the pattern to be an image, then do a save/restore, the
image is gone.

2) there is no way to specifically set the size of the annotation. it
automatically adapts to match the size of the text, but in this case, there
is no text - only an image. It would be nice if there was an image mode
called "Stretch" that would stretch the annotation to fit the image. Even
without that, I can't even programmatically set the size of the annotation
because those properties are not available.

I tried using a Tools.ChartImage, but that does not seem to work either. I
couldn't find any other Tools object that seems like it would accomplish
what I need to do.

Any suggestions?

Pep
Site Admin
Site Admin
Posts: 3295
Joined: Fri Nov 14, 2003 5:00 am
Contact:

Post by Pep » Tue Nov 25, 2003 11:00 pm

> Any suggestions?

My best suggestion is that you continue using the Annotation Tool, even
though the Steema.TeeChart.Drawing.Shape.Image property is not serialised to
the Template file (I've added this to the list of defects). The following
code works reasonably:

Steema.TeeChart.Styles.Line line1 = new
Steema.TeeChart.Styles.Line(tChart1.Chart);
Steema.TeeChart.Tools.Annotation annotation1 = new
Steema.TeeChart.Tools.Annotation(tChart1.Chart);
System.Drawing.Bitmap bitMap = new
System.Drawing.Bitmap(@"C:\Documents and Settings\sirhc\My
Documents\logo.gif");
System.Drawing.Rectangle r = new System.Drawing.Rectangle(bitMap.Width
/ 2, Convert.ToInt32(tChart1.Height - (bitMap.Height / 1.8)), bitMap.Width,
bitMap.Height);

line1.FillSampleValues(20);
annotation1.Shape.CustomPosition = true;
annotation1.Shape.Image = bitMap;
annotation1.Shape.ImageMode =
Steema.TeeChart.Drawing.ImageMode.Center;
annotation1.Shape.ShapeBounds = r;
annotation1.Shape.Pen.Visible = false;

There are going to be alternative ways to paint an image to a chart, for
example, with TeeChart AX & VB 6.0 we can do the following:

Private Sub Form_Load()
Dim i As Integer
Dim X As ListImage
'Load images into the ImageList.
For i = 1 To 9
Set X = ImageList1.ListImages. _
Add(, , LoadPicture(App.Path & "\OnTree" & i & ".jpg"))
Next i
'Relate TChart1 to TeeCommander1
TeeCommander1.Chart = TChart1
'Fill Chart
TChart1.Series(0).FillSampleValues 15
'Set Timer interval
TChart1.TimerInterval = 350
'Set start image
imageNum = 1
End Sub

Private Sub TChart1_OnBeforeDrawChart()
'Draw image to Chart Canvas
ImageList1.ListImages(imageNum).Draw TChart1.Canvas.HandleDC, 2000, 1000,
imlNormal
End Sub

I would imagine that similar methods could be using for TeeChart for .NET,
however, there is no advantage to them in the sense that they neither will
be able to save the image to the Template.

Josep Lluis Jorge
http://support.steema.com

Post Reply