Page 1 of 1

teechart .net cf font size and legend

Posted: Tue Mar 03, 2009 10:28 am
by 13051139
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

Posted: Tue Mar 03, 2009 3:44 pm
by narcis
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!

Posted: Wed Mar 04, 2009 7:46 am
by 13051139
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

Posted: Wed Mar 04, 2009 11:26 am
by narcis
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;

Posted: Wed Mar 04, 2009 11:51 am
by 13051139
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:)

Posted: Wed Mar 04, 2009 11:53 am
by narcis
Hi Igor,

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

Thanks in advance.

Posted: Wed Mar 04, 2009 12:05 pm
by 13051139
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.

Posted: Wed Mar 04, 2009 12:10 pm
by 13051139
Hi
I am sorry I misunderstood you.
I will try with BeforeZDrawSeries.
Thanks.

Posted: Wed Mar 04, 2009 12:39 pm
by 13051139
Great it works.
Thanks