TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
-
medved
- Newbie
- Posts: 3
- Joined: Fri Apr 12, 2013 12:00 am
Post
by medved » Fri Apr 19, 2013 8:40 pm
I have this code in a chart's Afterdraw:
Code: Select all
Code: Select all
Graphics3D g = TheChart.Graphics3D;
g.Font = TheChart.Axes.Top.Labels.Font;
g.Font.Bold = true;
...
g.TextOut(x, y, S);
the shown text is not bold (since the original Top.Labels.Font isn't bold).
The line "g.Font.Bold = true;", even though it does set the Bold property of the ChartFont type to true, has no effect on displayed font - since displayed font (DrawingFont) was already created.
so:
1. Why is there a "Bold" property if it has no effect?
2. How do I bold that font in order to show it on the canvas?
-
Sandra
- Site Admin
- Posts: 3132
- Joined: Fri Nov 07, 2008 12:00 am
Post
by Sandra » Mon Apr 22, 2013 7:26 am
Hello medved,
I inform you that using next code in latest version of TeeChartFor.Net(Build 4.1.2012.01312),in winforms, the text that I have drawn directly in the canvas, is set to bold if set g.Font.Bold to true.
Code: Select all
private void InitializeChart()
{
tChart1.Aspect.View3D = false;
Steema.TeeChart.Styles.Bar bar = new Steema.TeeChart.Styles.Bar(tChart1.Chart);
bar.MarksOnBar = true;
bar.Add(1, 1000);
bar.Add(2, 1200);
bar.Add(3, 900);
bar.Add(4, 800);
tChart1.Axes.Top.Visible = true;
bar.HorizAxis = HorizontalAxis.Top;
tChart1.AfterDraw += tChart1_AfterDraw;
}
void tChart1_AfterDraw(object sender, Graphics3D g)
{
g.Font = tChart1.Axes.Top.Labels.Font;
g.Font.Bold = true;
g.TextOut(50,100,"TeeChart");
}
Could you tell us which version of TeeChart are you using?
Thanks,
-
medved
- Newbie
- Posts: 3
- Joined: Fri Apr 12, 2013 12:00 am
Post
by medved » Mon Apr 22, 2013 8:36 am
Thank you, I found what line makes this (bolding text) not work - in my code, when initializing the chart, I assign a font to bottom axis:
Code: Select all
Ax.Labels.Font = new Steema.TeeChart.Drawing.ChartFont(mainChart.Chart, new System.Drawing.Font("Arial",8));
Once I do that, setting the Bold property no longer works.
I can see why that would be, I guess. I don't really need to set that custom font, I can just change the Name and Size properties of the existing font, then bolding works.
-
Sandra
- Site Admin
- Posts: 3132
- Joined: Fri Nov 07, 2008 12:00 am
Post
by Sandra » Mon Apr 22, 2013 2:00 pm
Hello medved,
Thanks for your extra information. My recommendation is, if you want always the text font works in correct way without problems, change the properties of font directly in canvas, as do in next simple code:
Code: Select all
private void InitializeChart()
{
tChart1.Aspect.View3D = false;
Steema.TeeChart.Styles.Bar bar = new Steema.TeeChart.Styles.Bar(tChart1.Chart);
bar.MarksOnBar = true;
bar.Add(1, 1000);
bar.Add(2, 1200);
bar.Add(3, 900);
bar.Add(4, 800);
tChart1.Axes.Top.Visible = true;
bar.HorizAxis = HorizontalAxis.Top;
tChart1.Axes.Top.Labels.Font.Name = "Arial";
tChart1.Axes.Top.Labels.Font.Size = 8;
tChart1.AfterDraw += tChart1_AfterDraw;
}
void tChart1_AfterDraw(object sender, Graphics3D g)
{
g.Font = tChart1.Axes.Top.Labels.Font;
g.Font.Bold = true;
g.TextOut(50, 100, "TeeChart");
}
I hope will helps.
Thanks,