Page 1 of 1

Bolding a font in Afterdraw...

Posted: Fri Apr 19, 2013 8:40 pm
by 16065624
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?

Re: Bolding a font in Afterdraw...

Posted: Mon Apr 22, 2013 7:26 am
by 10050769
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,

Re: Bolding a font in Afterdraw...

Posted: Mon Apr 22, 2013 8:36 am
by 16065624
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.

Re: Bolding a font in Afterdraw...

Posted: Mon Apr 22, 2013 2:00 pm
by 10050769
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,