Background image in Polar

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
SurveyBob
Newbie
Newbie
Posts: 22
Joined: Mon Dec 14, 2009 12:00 am

Background image in Polar

Post by SurveyBob » Mon Aug 09, 2010 8:44 am

Hello,

is it possible to have a Polar series with a background image just in the polar circle? I couldn't find any property to set this. It seems that a background image is only available for the whole TeeChart and not just the Polar series.

Am I missing something or is this a bug?
I'm using TeeChart for .NET 2009 (version 4.0.2009.42283).

Thanks in advance,
SurveyBob

SurveyBob
Newbie
Newbie
Posts: 22
Joined: Mon Dec 14, 2009 12:00 am

Re: Background image in Polar

Post by SurveyBob » Tue Aug 10, 2010 9:50 am

I found a workaround now and draw the image on my own.
In the constructor of the Form, I subscribe to the BeforeDrawValues event of the Polar and in the event handler I draw the image to a clipped region defined by the bounding rectangle of the Polar circle:

Code: Select all

public Form1()
{
	// ...
	m_Polar.BeforeDrawValues += new Steema.TeeChart.PaintChartEventHandler( m_Polar_BeforeDrawValues );
	// ...
	// Some points are added to m_Polar...
}

private void m_Polar_BeforeDrawValues( object sender, Steema.TeeChart.Drawing.Graphics3D g )
{
	Image image = Image.FromFile( @"C:\Windows\Web\Wallpaper\img25.jpg" );
	g.ClipEllipse( m_Polar.CircleRect );
	g.Draw( m_Polar.CircleRect, image, false );
	g.ClearClipRegions();
}
Now two problems arise:

1. When the Form is opened for the first time, the image doesn't appear yet. Only if during runtime points are added/changed or if the Form is resized, the image gets drawn.
I already tried overriding OnHandleCreated(), OnLoad(), OnResize(), etc. of Form and from that draw the image, but the problem then is that m_Polar.CircleRect is still empty, so I don't know the position/size of the polar circle.

2. When the Form is resized very quickly, the image is drawn with an offset. See the screenshot:
TChart Polar Background Image.jpg
TChart Polar Background Image.jpg (64.33 KiB) Viewed 5785 times
Do you have any ideas?

Thanks in advance,
SurveyBob

Yeray
Site Admin
Site Admin
Posts: 9612
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Background image in Polar

Post by Yeray » Tue Aug 10, 2010 3:03 pm

Hi SurveyBob,
SurveyBob wrote:1. When the Form is opened for the first time, the image doesn't appear yet. Only if during runtime points are added/changed or if the Form is resized, the image gets drawn.
I already tried overriding OnHandleCreated(), OnLoad(), OnResize(), etc. of Form and from that draw the image, but the problem then is that m_Polar.CircleRect is still empty, so I don't know the position/size of the polar circle.
I think that using Chart's BeforeDraw event would solve it:

Code: Select all

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

            Steema.TeeChart.Styles.Polar polar1 = new Steema.TeeChart.Styles.Polar(tChart1.Chart);
            polar1.Circled = true;
            
            polar1.FillSampleValues();

            tChart1.BeforeDraw += new Steema.TeeChart.PaintChartEventHandler(tChart1_BeforeDraw);
            tChart1.Draw();
        }

        void tChart1_BeforeDraw(object sender, Steema.TeeChart.Drawing.Graphics3D g)
        {
            Image image = Image.FromFile( @"C:\tmp\Yellow_solid_sphere.png" );
            g.ClipEllipse((tChart1[0] as Steema.TeeChart.Styles.Polar).CircleRect);
            g.Draw((tChart1[0] as Steema.TeeChart.Styles.Polar).CircleRect, image, false);
            g.ClearClipRegions();
        }
SurveyBob wrote:2. When the Form is resized very quickly, the image is drawn with an offset. See the screenshot:
Forcing a chart repaint solves it but, of course, it will be a little bit slower.

Code: Select all

        tChart1.Resize += new EventHandler(tChart1_Resize); // in InitializeChart

        void tChart1_Resize(object sender, EventArgs e)
        {
            tChart1.Draw();
        }
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

SurveyBob
Newbie
Newbie
Posts: 22
Joined: Mon Dec 14, 2009 12:00 am

Re: Background image in Polar

Post by SurveyBob » Wed Aug 25, 2010 11:37 am

Thanks, Yeray, that worked.
The redrawing really slows down resizing of the control pretty much, but for now, that's ok. At least it's drawn correct.

SurveyBob

Post Reply