6 Replies Latest reply on Jan 16, 2009 9:50 AM by Newsgroup_User

    Chart axis titles disappearing with image capture

    Cr99 Level 1
      I have the following code which generates a png file from a UIComponent (a panel with a chart in it). I have two different methods which are called to generate the image. One is automatically generated every few minutes, the other generates the image when a user hits a button to "save" the image. Both generate the chart fine, except that the automated version cuts the axis titles off for some reason. What is going on?


        • 1. Chart axis titles disappearing with image capture
          Cr99 Level 1
          I have an idea that this might be a problem with the asynchronous way methods get called in Flex. In other words even though code wise, the chart has been created before the automated image capture is called, somehow internally the chart is not complete. That's explains why the user triggered event of clicking the button works, but it doesn't explain why the automated calls to generate the image fail on the second and subsequent tries (since by then one would assume that the image has been created)

          By the way, I am using callLater(saveAllSnapshots) for the automated code.

          Could someone please help me with this?
          • 2. Re: Chart axis titles disappearing with image capture
            Cr99 Level 1

            I've made some progress. If I add this code:

            chartPanel.addEventListener(FlexEvent.CREATION_COMPLETE, imgExport);

            ////////////////////////////////////////////////////////////////
            // method: imgExport (Event)
            ////////////////////////////////////////////////////////////////

            public function imgExport(e:Event):void {
            var cp:ChartPanel = e.currentTarget as ChartPanel;
            captureImg(cp, cp.title);
            }

            The axis gets drawn, but only on the INITAL rendering of the chart (obviously). The addEventListener(FlexEvent.UPDATE_COMPLETE, imgExport) does not seem to register properly because the chartPanel doesn't ever get updated, just the data in the chart element whithin the panel. How do I get the update to register as an event as well?
            • 3. Re: Chart axis titles disappearing with image capture
              Level 7

              "Cr99" <webforumsuser@macromedia.com> wrote in message
              news:gklm8k$2d7$1@forums.macromedia.com...
              > I've made some progress. If I add this code:
              >
              > chartPanel.addEventListener(FlexEvent.CREATION_COMPLETE, imgExport);
              >
              > ////////////////////////////////////////////////////////////////
              > // method: imgExport (Event)
              > ////////////////////////////////////////////////////////////////
              >
              > public function imgExport(e:Event):void {
              > var cp:ChartPanel = e.currentTarget as ChartPanel;
              > captureImg(cp, cp.title);
              > }
              >
              > The axis gets drawn, but only on the INITAL rendering of the chart
              > (obviously). The addEventListener(FlexEvent.UPDATE_COMPLETE, imgExport)
              > does
              > not seem to register properly because the chartPanel doesn't ever get
              > updated,
              > just the data in the chart element whithin the panel. How do I get the
              > update
              > to register as an event as well?

              Maybe you need to register for the event on the chart, not the panel that
              creates it.


              • 4. Chart axis titles disappearing with image capture
                Cr99 Level 1
                I tried the following code, but the event never fires for the chart.

                • 5. Chart axis titles disappearing with image capture
                  Cr99 Level 1
                  The above code is faulty. I finally got it to work with the following code. And I should also add that only the event listener for the UPDATE_COMPLETE event is necessary. The CREATION_COMPLETE is redundant and you just add the single listener for the generic chart.

                  • 6. Re: Chart axis titles disappearing with image capture
                    Level 7

                    "Cr99" <webforumsuser@macromedia.com> wrote in message
                    news:gknldc$ncv$1@forums.macromedia.com...
                    > The above code is faulty. I finally got it to work with the following
                    > code.
                    > And I should also add that only the event listener for the UPDATE_COMPLETE
                    > event is necessary. The CREATION_COMPLETE is redundant and you just add
                    > the
                    > single listener for the generic chart.
                    >
                    >

                    The following code didn't follow, but I'm glad you got it to work :-)