Show logo in chart (c#)

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
Ralph
Newbie
Newbie
Posts: 2
Joined: Tue Nov 24, 2020 12:00 am

Show logo in chart (c#)

Post by Ralph » Fri Nov 27, 2020 5:39 am

How can I show a logo in the chart area?

I found that g.Draw(100, 100,img) in the BeforeDrawSeries does work, but I can't find a way to control the size or stretch the logo within a defined rectangle. Is there maybe a Teechart equivalent for e.Graphics.DrawImage(newImage, x, y, srcRect, units) that I'm not aware of?

I've also seen that this forum recommends to use the annotation tool for including images in charts, however my annotation tool only allows for text to be included, but not images? Is this feature limited to certain Teechart products?

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

Re: Show logo in chart (c#)

Post by Christopher » Mon Nov 30, 2020 8:43 am

Hello,

I would say the easiest and most powerful way to draw images to the Chart is to use one of the Draw overloads within one of TChart's custom drawing events. Here's an example of what I mean, using an image which has been added as a resource to the project:

Code: Select all

        private void InitializeChart(TChart chart)
        {
            void Chart_AfterDraw(object sender, Steema.TeeChart.Drawing.Graphics3D g)
            {
                var image = new Bitmap(Resources.shell);
                g.Draw(Utils.FromLTRB(100, 100, 300, 200), Utils.FromLTRB(0, 0, image.Width, image.Height), image, false);
            }

            chart.AfterDraw += Chart_AfterDraw;
        }
This gives me, as expected:
TeeChartNuGet_2020-11-30_09-34-45.png
TeeChartNuGet_2020-11-30_09-34-45.png (13.19 KiB) Viewed 5946 times
There are a number of TChart draw events which fire at different stages of TChart's rendering cycle, and these can be seen with reference to the Feature Demo on Steema's GitHub here - the relevant example being this one:
TeeChartNetExamples_2020-11-30_09-41-47.png
TeeChartNetExamples_2020-11-30_09-41-47.png (193.22 KiB) Viewed 5946 times
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