Cannot set chart height

TeeChart for ActiveX, COM and ASP
Post Reply
TGagnon
Newbie
Newbie
Posts: 7
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: 3303
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: 7
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: 3303
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

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

Re: Cannot set chart height

Post by TGagnon » Sun Apr 28, 2024 11:04 am

I have gutted out my program to the minimum code to show the issue. The code may not compile due to the gutting process, but the remaining code is enough to execute and show the issue.

To test:

1. Open the file
2. Open the VBA Development Environment
3. Open the modMain code block
4. Hit the Start button on the Home tab (this will load and set the starting size of the main form)
5. Find the SizeMainForm2 code in the modMain code block. This code sizes and positions all controls on the form.
6. Step through the code in SizeMainForm2
7. When you reach the last With block (With frmMain.TChartCombinedBondOrders), when the .width = 300 code is executed, the resulting value of .width will be 49151.25.

At this point there will be long pause then you will see that chart expand in width off the end of the form.

Before I stripped all the unneeded code, it was the .height value that was getting set to 49151.25. I'm not sure why the problem started showing up in the .width value instead.

I've saved, reopened, and tested this several times and I get the error every time. I hope you can also catch it.

Thank you.

Troy
Attachments
TChart Position Test.zip
(391.95 KiB) Downloaded 2460 times

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

Re: Cannot set chart height

Post by Pep » Mon Apr 29, 2024 4:13 pm

Hi Troy,
I've been trying to run the example you attached. In order to make it compilable and run I've had to comment and remove the lot of code, maybe more than enough.
At the end, as you can see in the image I've been able to run, but I can't see the Start button you comment to hit at the Home tab. Please, see the image.
If possible, it would be very good, in order to test and find a solution, if you can create a simple project were only se a Chart component and change size there by using button or similar. In order to try to find where the problem is and to go faster I think it would be the better option.

Thanks
AX-SIZE.jpg
AX-SIZE.jpg (102.86 KiB) Viewed 55633 times

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

Re: Cannot set chart height

Post by TGagnon » Mon Apr 29, 2024 5:10 pm

I'm sorry, I wasn't clear.

The Start button is on the "Home" sheet of Excel, not the Home tab.

Troy

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

Re: Cannot set chart height

Post by Pep » Tue May 07, 2024 7:25 am

Hi Troy,
just inform to you that we've been able to reproduce the problem by using your VBA application and that we're trying to find a solution. We'll back to you as soon as possible.
Thanks

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

Re: Cannot set chart height

Post by TGagnon » Wed May 08, 2024 11:49 am

I'm glad you were able to catch the problem. Looking forward to hearing what you find. Thanks for looking into this.

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

Re: Cannot set chart height

Post by TGagnon » Tue Jun 25, 2024 1:35 am

Hi. Just checking in. Have you found any cause for this issue yet?

Thanks.

Troy

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

Re: Cannot set chart height

Post by Pep » Tue Jun 25, 2024 7:14 am

Hello Troy,
sure, just inform to you that we've fixed this problem, and that we're just preparing a new maintenance release version that includes a fix for it. This new TeeChart for ActiveX maintenance release version will be out during today or tomorrow.

best regards!

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

Re: Cannot set chart height

Post by Pep » Tue Jun 25, 2024 11:30 am

Hello Troy,
just to inform that a new TeeChart ActiveX version v2024.0.6.25 has been published, you can download it through the customer area.
This version should fix your problem, but in order to fix at all, a minor change is requried to to in your code.It's to add a Form repaint after to change the width/height.
Like:

Code: Select all

With frmMain.TChartCombinedBondOrders
    .Width = 200
    .Height = 200
End With

frmMain.Repaint
Best regards!

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

Re: Cannot set chart height

Post by TGagnon » Sun Jun 30, 2024 10:21 pm

Thank you for the follow up.

When I look on the site, I don't see that version listed. Am I to presume that my upgrade option has expired and I have to repurchase the product?

Troy

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

Re: Cannot set chart height

Post by Pep » Thu Jul 04, 2024 8:04 am

Hello Troy,
let me check with sales and back to you.

regards,

Post Reply