Can someone from Adobe (or anyone, really) take a look at my example and see if they can figure out where the problem lies?

Thanks,

On 6/19/06, Pan Troglodytes <[EMAIL PROTECTED]> wrote:
Ah, I thought it had something to do with properties, but the help only says it's "Object", and it was set to null at runtime.  But this is a bit more clear.  I also figured you could do it by breaking it out, but I wanted to see how to manipulate it if I wanted to change it later.

I'm still running into a problem, though.  Check out the example code at:
http://three.fsphost.com/flex2/PieCategory/PieCategoryApp.html

When you click between the radio buttons, it changes the datasource and renderer like so:

      public var monthRenderer:ClassFactory = new ClassFactory(MonthRenderer);
      public var seasonRenderer:ClassFactory = new ClassFactory(SeasonRenderer);
     
      public function dataChange(e:Event):void {
        if (rg.selectedValue == "Months") {
          switchChart.setStyle ("itemRenderer", monthRenderer);
          switchChart.dataProvider = dataSet;
        }
        else {
          switchChart.setStyle("itemRenderer", seasonRenderer);
          switchChart.dataProvider = dataSet2;
        }
      }

      import com.adobe.viewsource.ViewSource;
      public function initApp(e:Event):void {
        ViewSource.addMenuItem (this, "srcview/index.html");

        dataChange(e);
      }

But the problem is that something sticks in the first renderer and isn't cleared out when you select the second one.  Notice that the only colored slices are the ones after the three slices in the original array.

Any ideas on why that is?



On 6/19/06, Ely Greenfield < [EMAIL PROTECTED]> wrote:

 
 
 
The ClassFactory class has a property called 'properties.'  This is a hash table (object) full of key/value pairs that get applied to instances generated by the ClassFactory as necessary. So in your case, your markup is saying 'create a PieCategoryWedgeRenderer, and when it gets created, assign an array of PieCategory objects to its categories property as needed'.
 
So you could do this:
 
var cf:ClassFactory = new ClassFactory(PieCategoryWedgeRenderer);
var tmp:Array = [];
var pc:PieCategory = new PieCategory();
pc.value = "Encouraged";
pc.color = 0x99ff99;
tmp.push(pc);
pc = new PieCategory();
pc.value = "Acceptable";
pc.color = 0x9999ff;
tmp.push(pc);
...
cf.properties = { 
    categories: tmp;
}
 
 
Alternatively, you could just copy the whole PieCategoryWedgeRenderer tag and contents from your markup into a separate MXML (call it MyPCWedgeRenderer.mxml) file to create a pre-customized subclass.  then:
 
var cf:ClassFactory = new ClassFactory(MyPCWedgeRenderer);
 
and you're done.
 
 
Ely.
 


Sent: Saturday, June 17, 2006 9:39 AM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Re: changing out pieSeries.itemRenderer at runtime

Okay, good start.  I was thrown off by the help topic"Flex 2.0 Developer's Guide > Customizing the User Interface > Using Item Renderers and Item Editors > Creating an item renderer and item editor".  It still uses the old non-setStyle method to set the itemRenderer.

Now how do I build this in code:

          <mx:itemRenderer>
              <mx:Component>
                  <nes:PieCategoryWedgeRenderer>
                      <nes:categories>
                          <nes:PieCategory value="Encouraged" color="#99FF99"/>
  &nbs! p;                       <nes:PieCategory value="Acceptable" color="#9999FF"/>

                          <nes:PieCategory value="Risk" color="#FFFF99"/>
                          <nes:PieCategory value="High Risk" color="#FF9999"/>
                      </nes:categories>
                  </nes:PieCategoryWedgeRenderer>
              </mx:Component>
          </mx:itemRenderer>


I've gotten this far:

public var riskRenderer! :ClassFa ctory = new ClassFactory(nes.charts.dataRenderers.PieCategoryWedgeRenderer);


Sadly, I'm lost after that.  I can't figure out how to add the categories.  Any tips?


--- In flexcoders@yahoogroups.com, "Ely Greenfield" <[EMAIL PROTECTED]> wrote:
>
>
>
> Item Renderer is a style. so you have to do this:
>
>
> ps.setStyle("itemRenderer", ... );
>
>
> What do you pass in as the value?
>
> 1) Passing null doesn't work. You've overridden the style, so you need
> ot set a new value. The default value is the class
> mx.charts.renderers.WedgeItemRenderer.
>
> 2) itemRenderers are typed as IFactory. Meaning they need to be an
> object that implements the IFactory interface. Flex ships with a
> default IFactory that simply wraps a class, called ClassFactory.
> So you want to do this:
>
> import mx.charts.rende! rers.WedgeItemRenderer;

>
> ps.setStyle("itemRenderer", new ClassFactory(WedgeItemRenderer));
>
> you'll probably have to import ClassFactory too...I don't remember what
> it's package is (probably mx.core), but you can find it in the AS doc
> reference.
>
> Ely.
>
>
> ________________________________
>
> From: flexcoders@yahoogroups.com [mailto: flexcoders@yahoogroups.com] On
> Behalf Of Jason
> Sent: Friday, June 16, 2006 4:19 PM
> To: flexcoders@yahoogroups.com
> Subject: [flexcoders] changing out pieSeries.itemRenderer at runtime
>
>
>
> Okay, so I've made an itemRenderer for a pieSeries. But sometimes I
> want to turn it off. How might I go about that?
>
> <mx:PieSeries id="ps" field="time" labelPosition="insideWithCallout"
> labelFunction="getLabel"
> dataProvider="{chartData}" insideLa! belSizeLimit="10"
> fontSize="10">
> ! <mx:i temRenderer>

> <mx:Component>
> <nes:PieCategoryWedgeRenderer>
> <nes:categories>
> <nes:PieCategory va! lue="Encouraged"
> color="#99FF99"/>
> <nes:PieCategory value="Acceptable"
> color="#9999FF"/>
> <nes:PieCategory value="Risk"
> color="#FFFF99"/>
> <nes:PieCategory value="High Risk"
> color="#FF9999"/>
> </nes:categories>
> </nes:PieCategoryWedgeRenderer>
> </mx:Component>
> </mx:itemRen! derer>
> </mx:PieSeries>
>
>
> < /font>PieCategoryWedgeRenderer is a class I wrote that I mentioned in
> another thread. So now in some function in the applicatio! n, I want to

> say:
>
> ps.itemRenderer = null;
>
> or even
>
> ps.itemRenderer.categories[0].value = "NewTitle";
>
> I've read through all the help and can't figure out how I would actually
> do that. FB says it has no idea what "ps.itemRenderer" is referring to.
> So that kinda stumps me.
>




--
Jason



--
Jason __._,_.___

--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com





SPONSORED LINKS
Web site design development Computer software development Software design and development
Macromedia flex Software development best practice


YAHOO! GROUPS LINKS




__,_._,___

Reply via email to