6 Replies Latest reply on Dec 17, 2009 6:15 AM by kirant400

    Component resizing problem in Vbox

    kirant400

      Hi.. I am facing a peculiar problem.. I have a vbox which contains 5 components, each of which has a line graph and a legend.. But all of them need not be visible at a time.. It depends on the number of parameters returned from a webservice call... so at a time 1-5 of such components maybe visible... i do this by setting includeInLayout and visible to false..

       

      Each of the components have height and width set to 100%. So I expect all the components which have includeinlayout and visible set to true to be equal in size... But if initially only one of the component is visible and then i want to show 2 components by setting these properties, the component which was visible initially is not resizing.. It is staying the same size as before making the second component visible... second component is getting correct size (half of the size of the VBox)..... Am i doing something wrong here? Can some component not reduce in size if another child added/included in layout of its parent?

       

      Thanks in advance for your help!

        • 1. Re: Component resizing problem in Vbox
          PhilipKeiter Level 2

          Kirant,

           

          What you are trying to do usually works as expected. Can you show some code?

           

          Thanks,

          Philip

          • 2. Re: Component resizing problem in Vbox
            kirant400 Level 1

            Hi Philip,

             

            This is my vbox declaration. Trendline has a linechart and a legend

             

            <mx:VBox id="chartsContainer" width="100%" height="100%" verticalScrollPolicy="auto">
               <chart:TrendLine id="defaultTrendLineChart" width="100%" height="100%" includeInLayout="true" visible="true"/>
               <chart:TrendLine id="trendChart1" width="100%" height="100%" includeInLayout="false" visible="false"/>
               <chart:TrendLine id="trendChart2" width="100%" height="100%" includeInLayout="false" visible="false"/>
            </mx:VBox>


            And here is the code where i selectively include various charts in the display

             

            var count:int = 0;

            for (var parameterType:String in parameterTable)

            {

               var trendLineChart:TrendLine = trendChartArray[count++];                                                       
               trendLineChart.includeInLayout = true;
               trendLineChart.visible = true;
               trendLineChart.Initialize();
               trendLineChart.SetView(bIsChartView);                       
               trendLineChart.LoadChart(dataProvider, parameterType, parameterTable[parameterType]);

             

             

            I have stored all the children of the vbox in an array for easy fetching

             

            var trendChartArray:Array = [defaultTrendLineChart, trendChart1, trendChart2];

             

            parameterTable is a Dictionary in which number of parametertypes can vary from 1 to 3 depending on the result of a webservice call. The problem is that if initially i am showing only one chart and then i have to show 2 charts, the first chart's size is not getting reduced. But the second chart added is getting correct size.

             

            Thanks a lot for your response.

            • 3. Re: Component resizing problem in Vbox
              Wiouou

              I don't think you need includeInLayout, the parent uses the child but doesn't update it's position, and initialize ().  I'd try validateNow () on chartsContainer.

              • 4. Re: Component resizing problem in Vbox
                kirant400 Level 1

                But if i am not using includeinlayout then space is getting reserved for

                invisible items and blank space is coming in the container.


                • 5. Re: Component resizing problem in Vbox
                  Gregory Lafrance Level 6

                  What is TrendLine, a custom chart? Maybe you need to call invalidateDisplayList() in your custom chart after it loads.

                   

                  Are you executing this for look anytime user makes choices as to what to display? If so, seems like it is better to have something like if(!tendLineChart) so it is only loaded once.

                   

                  for (var parameterType:String in parameterTable)

                  {

                     var trendLineChart:TrendLine = trendChartArray[count++];                                                        
                     trendLineChart.includeInLayout = true;
                     trendLineChart.visible = true;
                     trendLineChart.Initialize();
                     trendLineChart.SetView(bIsChartView);                       
                     trendLineChart.LoadChart(dataProvider, parameterType, parameterTable[parameterType]);

                  }

                   

                  If this post answers your question or helps, please mark it as such.


                  Greg Lafrance
                  www.ChikaraDev.com

                  Flex Development and Support Services

                  1 person found this helpful
                  • 6. Re: Component resizing problem in Vbox
                    kirant400 Level 1

                    No user can make changes and reload the whole thing. So i have to make changes appropriately

                    . This is where the problem starts actually.