10 Replies Latest reply on Aug 15, 2008 10:03 AM by Newsgroup_User

    chartItem custom itemRenderer almost done

    Jed Schneider Level 1
      Hi everyone, I have a customItem renderer (from the Flex Cookbook by Noble and Anderson, 2008) that adds an image that is embeded when compiled but what i really need is to update the image with a different image for each chartItem. I have confirmed with a trace statement (see code) that I can access the path of the needed file for each datapoint (chartItem) in the lineChart. I think the solution is the 1) create the img as a Bindable variable
      2) create a new Image and set the source as the file path
      3) somehow take that image and use it as the display object

      ...am I on the right track here? I tried without making the variable bindable and it didn't work, so I though I'd ask first. I figured it would work since the Image class inherits the displayObject properties. Thanks in advance.
      Jed

        • 1. Re: chartItem custom itemRenderer almost done
          Jed Schneider Level 1
          Refreshing this request. Thank You.
          • 2. Re: chartItem custom itemRenderer almost done
            Level 7

            "Jed Schneider" <webforumsuser@macromedia.com> wrote in message
            news:g7t1hp$e19$1@forums.macromedia.com...
            > Hi everyone, I have a customItem renderer (from the Flex Cookbook by Noble
            > and
            > Anderson, 2008) that adds an image that is embeded when compiled but what
            > i
            > really need is to update the image with a different image for each
            > chartItem. I
            > have confirmed with a trace statement (see code) that I can access the
            > path of
            > the needed file for each datapoint (chartItem) in the lineChart. I think
            > the
            > solution is the 1) create the img as a Bindable variable
            > 2) create a new Image and set the source as the file path
            > 3) somehow take that image and use it as the display object
            >
            > ...am I on the right track here? I tried without making the variable
            > bindable
            > and it didn't work, so I though I'd ask first. I figured it would work
            > since
            > the Image class inherits the displayObject properties. Thanks in advance.

            This example
            http://examples.adobe.com/flex2/inproduct/sdk/photoviewer/PhotoViewer.html
            might give you some ideas. Right click to view source.


            • 3. Re: chartItem custom itemRenderer almost done
              Jed Schneider Level 1
              Amy this is a great lead, I'll let you know how it turns out. thanks.
              • 4. Re: chartItem custom itemRenderer almost done
                Level 7

                "Jed Schneider" <webforumsuser@macromedia.com> wrote in message
                news:g7uojf$c2p$1@forums.macromedia.com...
                > Amy this is a great lead, I'll let you know how it turns out. thanks.

                You're welcome :-)


                • 5. Re: chartItem custom itemRenderer almost done
                  Jed Schneider Level 1
                  This is probably a silly question, but I'm a noob so I am going to ask anyway. In the example code I posted, using the Embed metatag, this is basically replacing the constructor in the class. Am I correct in stating this?
                  • 6. Re: chartItem custom itemRenderer almost done
                    Level 7

                    "Jed Schneider" <webforumsuser@macromedia.com> wrote in message
                    news:g7uqmd$eb8$1@forums.macromedia.com...
                    > This is probably a silly question, but I'm a noob so I am going to ask
                    > anyway.
                    > In the example code I posted, using the Embed metatag, this is basically
                    > replacing the constructor in the class. Am I correct in stating this?

                    Which class?


                    • 7. Re: chartItem custom itemRenderer almost done
                      Jed Schneider Level 1
                      Sorry, let me restate and expand:
                      PhotoDatapointRenderer is the name of the custom class in the code I posted above. As far as I can tell, the class that I am extending -ProgrammaticSkin - has a constructor method but the IDataRenderer class I am implementing does not (only get and set methods).

                      As mentioned I grabbed this example above from the Flex Cookbook and that example had no constructor method. But by embedding an image at the time of compile the debugger is telling me that all the properties associated with an image file are there, so by Embedding the image, the compiler is "constructing", I think.

                      In the source code example provided by Amy a constructor is called and I believe all the public and private methods required for an Image class are notably overwritten. A programmatic skin has no specified methods in the constructor, if I understand the language ref. correctly.

                      In order for me to get the desired effect of putting a unique image in each chartItem I think I have to create constructor method - in this case public function PhotoDatapointRenderer( ) constructing an object that can be passed to the updateDisplayList method. Does this seem logical?
                      • 8. Re: chartItem custom itemRenderer almost done
                        Level 7

                        "Jed Schneider" <webforumsuser@macromedia.com> wrote in message
                        news:g7uu9d$i25$1@forums.macromedia.com...
                        > Sorry, let me restate and expand:
                        > PhotoDatapointRenderer is the name of the custom class in the code I
                        > posted
                        > above. As far as I can tell, the class that I am
                        > extending -ProgrammaticSkin -
                        > has a constructor method but the IDataRenderer class I am implementing
                        > does not
                        > (only get and set methods).
                        >
                        > As mentioned I grabbed this example above from the Flex Cookbook and that
                        > example had no constructor method. But by embedding an image at the time
                        > of
                        > compile the debugger is telling me that all the properties associated with
                        > an
                        > image file are there, so by Embedding the image, the compiler is
                        > "constructing", I think.
                        >
                        > In the source code example provided by Amy a constructor is called and I
                        > believe all the public and private methods required for an Image class are
                        > notably overwritten. A programmatic skin has no specified methods in the
                        > constructor, if I understand the language ref. correctly.
                        >
                        > In order for me to get the desired effect of putting a unique image in
                        > each
                        > chartItem I think I have to create constructor method - in this case
                        > public
                        > function PhotoDatapointRenderer( ) constructing an object that can be
                        > passed
                        > to the updateDisplayList method. Does this seem logical?

                        To be honest, I think the example you found is overkill for just using a
                        graphic as an itemRenderer.
                        http://www.adobe.com/livedocs/flex/3/html/help.html?content=charts_formatting_12.html
                        Creating graphical renderers
                        You can use a graphic file such as a GIF or JPEG to be used as a renderer on
                        the chart series. You do this by setting the value of the itemRenderer style
                        property to be an embedded image. This method of graphically rendering chart
                        items is similar to the graphical skimming method used for other components,
                        as described in Creating graphical skins.

                        The way I'd probably handle this if it were my own project is to extend
                        whichever series you're using to have an iconFunction and create a renderer
                        that can use that info. This weekend I expect to be posting code for an
                        extended TileList that has a styleFunction added to it and an extended
                        button that can take an icon passed in through the iconFunction that
                        TileList already has and use that as its icon. Note that I don't change
                        anything about how the button actually implements the icon, but these files
                        may get you closer to your goal. If I have time, I'll look at adding these
                        to the posting.

                        Watch this space for more info:
                        http://flexdiary.blogspot.com

                        HTH;

                        Amy


                        • 9. Re: chartItem custom itemRenderer almost done
                          Jed Schneider Level 1
                          Hi Amy,
                          Thanks again for the advice. I am starting to agree with you on the "overkill" issue, but it was the only way that I could seem to find to dynamically change the image at each data point on the graph. Now I am working on adding the images to an ArrayCollection as bitmapData, then creating a vBox mxml component and setting its source to the {data.bitmapdata} value. Do you think that would work?

                          I will and have been checking your blog. Without all your dissemination on Flex, my learning curve with Flex would be much longer. Thank you, and all of you Flex folks who share the knowledge.

                          Jed
                          • 10. Re: chartItem custom itemRenderer almost done
                            Level 7

                            "Jed Schneider" <webforumsuser@macromedia.com> wrote in message
                            news:g84b4g$k4f$1@forums.macromedia.com...
                            > Hi Amy,
                            > Thanks again for the advice. I am starting to agree with you on the
                            > "overkill"
                            > issue, but it was the only way that I could seem to find to dynamically
                            > change
                            > the image at each data point on the graph. Now I am working on adding the
                            > images to an ArrayCollection as bitmapData, then creating a vBox mxml
                            > component
                            > and setting its source to the {data.bitmapdata} value. Do you think that
                            > would
                            > work?
                            >
                            > I will and have been checking your blog. Without all your dissemination on
                            > Flex, my learning curve with Flex would be much longer. Thank you, and all
                            > of
                            > you Flex folks who share the knowledge.

                            I do this because my learning curve was hugely painful LOL.