Page 1 of 1

How to add an image to annotation tool

Posted: Mon Feb 23, 2015 6:03 am
by 15669247
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?

Re: How to add an image to annotation tool

Posted: Mon Feb 23, 2015 9:42 am
by Christopher
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"));
    }

Re: How to add an image to annotation tool

Posted: Wed Feb 25, 2015 6:08 am
by 15669247
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?

Re: How to add an image to annotation tool

Posted: Wed Feb 25, 2015 2:30 pm
by Christopher
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")));
    }