How to add an image to annotation tool

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
Dev01
Newbie
Newbie
Posts: 4
Joined: Tue May 13, 2014 12:00 am

How to add an image to annotation tool

Post by Dev01 » Mon Feb 23, 2015 6:03 am

Can we use annotation tool to add an image with TeeChart for .Net using WPF?
The forum, in one of the answers does provide a snippet to add an image. The primary understanding is that the code snippet is for TeeChart for .Net and it should work with WPF. We observe that it does not work at our end with WPF.
Is there any other way we can add an image? Are there any other features for adding a small annotation image on / above the chart area?

Christopher
Guru
Posts: 1603
Joined: Fri Nov 15, 2002 12:00 am

Re: How to add an image to annotation tool

Post by Christopher » Mon Feb 23, 2015 9:42 am

Dev01 wrote:
Is there any other way we can add an image? Are there any other features for adding a small annotation image on / above the chart area?
The following code works as expected with TeeChart.WPF.dll version 4.1.2014.12150:

Code: Select all

    Annotation tool = new Annotation();
    Line series = new Line();

    private void InitializeChart()
    {
      //series = new LinePoint(tChart1.Chart);
      //series.FillSampleValues();

      tChart1.Aspect.View3D = false;
      tChart1.Legend.Visible = false;

      tChart1.Series.Add(series);
      series.FillSampleValues();

      tChart1.Tools.Add(tool);
      tool.Text = "Hello there";
      tool.AutoSize = false;
      tool.Height = 200;
      tool.Width = 300;

      tool.Shape.Image = new BitmapImage(new Uri(@"C:\MyPath\myimage.png"));
    }
Best Regards,
Christopher Ireland / 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

Dev01
Newbie
Newbie
Posts: 4
Joined: Tue May 13, 2014 12:00 am

Re: How to add an image to annotation tool

Post by Dev01 » Wed Feb 25, 2015 6:08 am

Thank you Christopher. I have tried the same code, but with TeeChart.WPF.dll version 4.1.2014.5092. This does not work as expected.
We see the mulitple images tiled in the Annotation tool. We have tried all the different properties related to image for the Annotation tool (Like Strech, Fit, etc.) Still we see the same.
Is this related to the version I use? Is there any other way we can achieve the functionality?

Is there a way we can add an image using TeeChart.dll in a WPF UI?

Christopher
Guru
Posts: 1603
Joined: Fri Nov 15, 2002 12:00 am

Re: How to add an image to annotation tool

Post by Christopher » Wed Feb 25, 2015 2:30 pm

Dev01 wrote:Is there a way we can add an image using TeeChart.dll in a WPF UI?
For absolute control of image rendering, you can use the AfterDraw event, e.g.

Code: Select all

    Line series = new Line();

    private void InitializeChart()
    {
      tChart1.Aspect.View3D = false;
      tChart1.Legend.Visible = false;

      tChart1.Series.Add(series);
      series.FillSampleValues();

      tChart1.AfterDraw += tChart1_AfterDraw;
    }

    void tChart1_AfterDraw(object sender, Graphics3D g)
    {
      g.Draw(100, 100, new BitmapImage(new Uri(@"D:\Program Files (x86)\Steema Software\Steema TeeChart for .NET 2014 4.1.2014.05090\Docs\images\image003.jpg")));
    }
Best Regards,
Christopher Ireland / 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

Post Reply