teechart .net cf font size and legend

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
Igor G
Newbie
Newbie
Posts: 16
Joined: Thu Dec 11, 2008 12:00 am

teechart .net cf font size and legend

Post by Igor G » Tue Mar 03, 2009 10:28 am

Hi
I am using TeeChart Pocket version 3.5.3274.30664 for CF 3.5
I have 2 questions:
1. I am trying to draw on the chart surface in AfterDraw event. I need to draw kind of watermark on the chart. My idea was to draw a string using big font. The problem is that the string is drawn but in small font. I wanted to use font size 50 and it doesnt work.
My code is (in the AfterDraw event):

waterMarkFont = new ChartFont(chart.Chart, new Font("Verdana", 50F, FontStyle.Bold));
waterMarkFont.Brush.Color = Color.FromArgb(130, 219, 190);
g.TextOut(waterMarkFont, 100, 200);

2. This is a chart example with legeng on right side:

---------------
CHART AREA ---- SERIES1
CHART AREA ---- SERIES2
---------------

I dont want to show the colored line in the legend. Instead of this I want to have each series name in the legend colored by its color. Is it possible to do? The idea is to save a little bit space on the screen.

Thanks a lot,
Regards

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Tue Mar 03, 2009 3:44 pm

Hi Igor,

1. This works fine:

Code: Select all

		void tChart1_AfterDraw(object sender, Steema.TeeChart.Drawing.Graphics3D g)
		{
			g.Font.Name = "Verdana";
			g.Font.Size = 20;
			g.TextOut(10, 20, "hello world!");
		}
2. Yes, you could try turning off legend symbols:

Code: Select all

			tChart1.Legend.Symbol.Visible = false;
And implement GetLegendText event like this:

Code: Select all

		void tChart1_GetLegendText(object sender, GetLegendTextEventArgs e)
		{
			if (e.Index<tChart1.Series.Count)
			{
				tChart1.Graphics3D.Font.Color = tChart1[e.Index].Color; 
			}
		}
Hope this helps!
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Igor G
Newbie
Newbie
Posts: 16
Joined: Thu Dec 11, 2008 12:00 am

Post by Igor G » Wed Mar 04, 2009 7:46 am

Hi
Thanks for your help.

1. This works, but the text is drawn UPON the Line and what I need is to draw it like watermark on the chart surface. I have tryed to do it in BEforeDRaw event but in this case the text is drawn BELOW the Panel...
Do you have any ideas?

2. It eliminates symbols but the legend is colored the same color inspite of that each Line has its own. I have seen in debugger that the Series[index].Color is correct but Graphics3D.Font.Colore ignores it.
The legend is drawn with the first color.

Thanks

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Wed Mar 04, 2009 11:26 am

Hi Igor,
1. This works, but the text is drawn UPON the Line and what I need is to draw it like watermark on the chart

surface. I have tryed to do it in BEforeDRaw event but in this case the text is drawn BELOW the Panel...
Do you have any ideas?
Yes, you can do it in the BeforeDrawSeries event:

Code: Select all

		void tChart1_BeforeDrawSeries(object sender, Graphics3D g)
		{
			g.Font.Name = "Verdana";
			g.Font.Size = 20;
			g.TextOut(10, 20, "hello world!"); 
		}
2. It eliminates symbols but the legend is colored the same color inspite of that each Line has its own. I have

seen in debugger that the Series[index].Color is correct but Graphics3D.Font.Colore ignores it.
The legend is drawn with the first color.
It's much easier than I expected because you can use FontSeriesColor property for that:

Code: Select all

			Steema.TeeChart.Styles.Line line1 = new Steema.TeeChart.Styles.Line(tChart1.Chart);
			Steema.TeeChart.Styles.Line line2 = new Steema.TeeChart.Styles.Line(tChart1.Chart);
			Steema.TeeChart.Styles.Line line3 = new Steema.TeeChart.Styles.Line(tChart1.Chart);

			line1.FillSampleValues();
			line2.FillSampleValues();
			line3.FillSampleValues();

			tChart1.Legend.Symbol.Visible = false;
			tChart1.Legend.FontSeriesColor = true;
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Igor G
Newbie
Newbie
Posts: 16
Joined: Thu Dec 11, 2008 12:00 am

Post by Igor G » Wed Mar 04, 2009 11:51 am

Yes, you can do it in the BeforeDrawSeries event:
Code:
void tChart1_BeforeDrawSeries(object sender, Graphics3D g)
{
g.Font.Name = "Verdana";
g.Font.Size = 20;
g.TextOut(10, 20, "hello world!");
}
I mean that if I do it the text is drawn BENEATH the chart and not ON the chart itself...
I hope I am clear:)

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Wed Mar 04, 2009 11:53 am

Hi Igor,

This is TChart's BeforeDrawSeries not general BeforeDraw event. Have you tried if this works fine at your end?

Thanks in advance.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Igor G
Newbie
Newbie
Posts: 16
Joined: Thu Dec 11, 2008 12:00 am

Post by Igor G » Wed Mar 04, 2009 12:05 pm

This is my code:

chart.BeforeDraw += chart_BeforeDraw;

............


void chart_BeforeDraw(object sender, Graphics3D g)
{
g.Font.Name = "Verdana";
g.Font.Size = 20;
g.TextOut(10, 20, "hello world!");
}


The "hello world" is drawn benetah the chart area and when lines are drawn all the chart area is over the text.
I can send a picture if its not clear.

Igor G
Newbie
Newbie
Posts: 16
Joined: Thu Dec 11, 2008 12:00 am

Post by Igor G » Wed Mar 04, 2009 12:10 pm

Hi
I am sorry I misunderstood you.
I will try with BeforeZDrawSeries.
Thanks.

Igor G
Newbie
Newbie
Posts: 16
Joined: Thu Dec 11, 2008 12:00 am

Post by Igor G » Wed Mar 04, 2009 12:39 pm

Great it works.
Thanks

Post Reply