Referencing component widths

Hello.

I am trying to center components on my form.

I have a jqxChart on my form. I am using the following to center the chart

var posX2 = (winWidth/2) - ($("#Chart1").width()/2) + $(window).scrollLeft()

I have found the value of $("#Chart1).width is changing when I move to different forms and come back.
So I tried using Chart1.Width and that did even less for me.

Can someone explain why my chart width is changing without any explicit changes to the chart’s width and what are the rules in referencing components.

Thank you,
Robb

I created a demo project.

Form1 and Form2
Form 1 show my chart component of 320px ; then I change the visibility of the components go to form2 and then back to form1 and the widths change. I wouldn’t think visibility would not change my widths of components.

SampleWidthEx.nsx (21.4 KB)

console output

width and cwidth are showing the same width by two different references to the component.

The jqxChart decides its own width, based on whatever it uses to decide. A useful event is

Chart1.onresize = function() {
    //some code
}

which you can use to move the chart as needed.

In BASIC, that’s

Function Chart1_onsize()
  ' some code
End Function

Another approach which sometimes works is to set left to 5% and width to 90%.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.