Cannot set chart height

TeeChart for ActiveX, COM and ASP
Post Reply
TGagnon
Newbie
Newbie
Posts: 2
Joined: Tue Feb 04, 2020 12:00 am

Cannot set chart height

Post by TGagnon » Sat Feb 10, 2024 1:34 am

I cannot set the height of a chart. I'm trying to use a simple formula to calculate how much space I have available on a VBA multipage control on a form (in Excel) after I load a few other objects. Whatever space I have left on the from, I'd like to use for the chart.

Code: Select all


With frmMain.TChart1
           .Top = frmMain.iGrid1.Top + frmMain.iGrid1.Height
           .Left = 0
           .Height = frmMain.MultiPage1.Height - frmMain.iGrid1.Height - frmMain.iGrid2.Height - frmMain.TChart2.Height
           .Width = frmMain.FrameHomeRibbon.Width * 0.28
End With

I hope I've posted the code correctly.

When setting the Height property, it's not working. If I assign the right side of the equation to a variable (so I can see what the value is), I get, say, 100. But after I assign it to the Height property, the Height property is a different number, say 50.

iVariable = frmMain.MultiPage1.Height - frmMain.iGrid1.Height - frmMain.iGrid2.Height - frmMain.TChart2.Height
.Height = iVariable

Either way, the Height property is not being set correctly. It's like it ignores the right side of the equation - or at least comes up with a seemingly random number.

I've done the math on a piece of paper, and I am confident that I should have (using my fake numbers above) 100 pixels which validates the right side of the equation.

Not sure if it matters, but there are three charts on the same page of the multipage control, all at the same .Top and all the same .Width.

I am using TChart Pro V2021.0.2.10

What am I missing?

Thanks.

Pep
Site Admin
Site Admin
Posts: 3273
Joined: Fri Nov 14, 2003 5:00 am
Contact:

Re: Cannot set chart height

Post by Pep » Tue Feb 13, 2024 2:19 pm

Hello,
I understand that you're trying to change the height of control itself. In that way, have you tried to change the height directly through Controls property ?

By using something like:

Code: Select all

Controls[1].Height = 50;

TGagnon
Newbie
Newbie
Posts: 2
Joined: Tue Feb 04, 2020 12:00 am

Re: Cannot set chart height

Post by TGagnon » Fri Apr 12, 2024 8:34 pm

I tried setting the width and height outside the "With" block, using a fixed value (300). When stepping through the code, the frmMain.TChartCABondOrder.Height value is always 49151.25. It completely ignores the "300". So it's not the "With" block. I've tried setting a long variable to 300 then setting the .Height to that variable, but still get the same results: 49151.25.

I looked at the Controls option, but was not able to make that work. I don't know how to reference the TChartCABondOrders control by number. I did a debug.print to print out all the controls, but I don't see how to reference it by number.

Code: Select all

            With frmMain.TChartCABondOrders
                .Top = 25
                .Left = 0
'                .Height = lHeight
'                .Width = lWidth
            End With
            frmMain.TChartCABondOrders.Height = 300
            frmMain.TChartCABondOrders.Width = 300
 

Pep
Site Admin
Site Admin
Posts: 3273
Joined: Fri Nov 14, 2003 5:00 am
Contact:

Re: Cannot set chart height

Post by Pep » Mon Apr 15, 2024 9:34 pm

Hello,

ok.
Could you please attach a very simple example that includes a Chart component on it and with which we can reproduce the problem as is here ?

Thanks

Post Reply