Page 1 of 1

Show logo in chart (c#)

Posted: Fri Nov 27, 2020 5:39 am
by 21089982
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?

Re: Show logo in chart (c#)

Posted: Mon Nov 30, 2020 8:43 am
by Christopher
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 6827 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 6827 times