Problem fixed. Here is the code. It seems a little stupid but it 
works. var colors value is same with the value in chart series 
render, so we can get the same color.

  <mx:Legend dataProvider="{countryList}" initialize="initLegend()" 
direction="horizontal" markerHeight="5" markerWidth="5" width="100%"/>

  function initLegend() {
          var fill : SolidColor;
          var stroke : Stroke = new Stroke(0x001100);
          var label : String;
          var keyItems = new Array();
          var colors = 
[0x550000,0x660000,0x770000,0x880000,0x990000,0xAA0000,0xBB0000,0xCC00
00,0xDD0000,0xEE0000,0xFF0000,
                                   
0x005500,0x006600,0x007700,0x008800,0x009900,0x00AA00,0x00BB00,0x00CC0
0,0x00DD00,0x00EE00,0x00FF00,
                                   
0x000055,0x000066,0x000077,0x000088,0x000099,0x0000AA,0x0000BB,0x0000C
C,0x0000DD,0x0000EE,0x0000FF];
          for (var i = 0; i < csaRO1.getElements.result.length; 
i++) {
                  fill = new SolidColor(colors[i]);
                  keyItems[i]={label:csaRO1.getElements.result
[i].name,fill:fill,stroke:stroke};
          }
          countryList = keyItems;
  }


--- In [email protected], "wujunjr" <[EMAIL PROTECTED]> wrote:
>
> Thanks. I'm afraid it is not suitable for me to use LegendItem 
since 
> there are over 30 plots on one chart. And there are many charts in 
> the application.
> Could you kindly give me an example about make a series or 
> chart "extends Series/ChartBase"?
> Maybe we can use the function "get legendData():", but I don't know 
> how.
> 
> Thanks a lot!
> 
> --- In [email protected], "Ely Greenfield" <egreenfi@> 
> wrote:
> >
> > 
> > 
> > 
> > So you want to use one series, but have multiple items show up in 
> the
> > legend?
> > 
> > There are ways to make a series do this through subclassing 
> (PieSeries
> > does this, for example), but for you the easiest thing might be 
to 
> just
> > build your legend manually.  Rather than hooking up your legend 
to a
> > chart, you can explicitly populate it with LegendItems (like you 
> would a
> > Vbox).  LegendItems use renderers to draw their markers just like 
> series
> > do, so if necessary you can write custom renderers for your 
legend 
> items
> > as well.
> > 
> > Ely.
> > 
> > 
> > -----Original Message-----
> > From: [email protected] 
> [mailto:[EMAIL PROTECTED] On
> > Behalf Of wujunjr
> > Sent: Wednesday, February 22, 2006 2:55 AM
> > To: [email protected]
> > Subject: [flexcoders] Re: different color and shape in one plot 
> chart
> > 
> > Ely,
> > 
> > Thank you so much.
> > Your examples are terrific!
> > But, when I did it that way, the Legend of the chart cannot work
> > correctly (only display one item) even if I use the same renderer 
> with
> > PlotChart.
> > 
> > Also, is there any way to add a lable on the top of a column 
chart?
> > 
> > Regards,
> > John
> > 
> > --- In [email protected], "Ely Greenfield" <egreenfi@>
> > wrote:
> > >
> > > 
> > > 
> > > 
> > > There's a solution in both Flex 1.5 and Flex 2, but it's easier 
in
> > Flex
> > > 2.
> > > 
> > > 
> > > In Flex 1.5, you'll want to looking into building a custom 
> renderer
> > (I
> > > just posted an example a few days ago of doing this for a 
column 
> > > chart...doing it for a PlotChart is esentially the same).
> > > 
> > > In Flex 2, you'd build a custom itemSkin...again, I posted an
> > example of
> > > this recently for columnCharts.
> > > 
> > > Ely.
> > >  
> > > 
> > > -----Original Message-----
> > > From: [email protected]
> > [mailto:[EMAIL PROTECTED] On
> > > Behalf Of wujunjr
> > > Sent: Tuesday, February 21, 2006 6:56 PM
> > > To: [email protected]
> > > Subject: [flexcoders] Re: different color and shape in one plot
> > chart
> > > 
> > > Is there any solution in Flex 2?
> > > I'm using Flex 1.5 now.
> > > 
> > > Thanks.
> > > John
> > > 
> > > --- In [email protected], "Ely Greenfield" <egreenfi@>
> > > wrote:
> > > >
> > > > 
> > > > 
> > > > 
> > > > This is probably starting to sound repetetive, but...
> > > > 
> > > > 
> > > > Flex 1.5 or 2?
> > > > 
> > > > E.
> > > >  
> > > > 
> > > > -----Original Message-----
> > > > From: [email protected]
> > > [mailto:[EMAIL PROTECTED] On
> > > > Behalf Of wujunjr
> > > > Sent: Tuesday, February 21, 2006 1:11 AM
> > > > To: [email protected]
> > > > Subject: [flexcoders] different color and shape in one plot 
> chart
> > > > 
> > > > Hi, all,
> > > > 
> > > > Is it possible to implement a plot chart in flex, which have
> > > different
> > > > color and shape within same PlotSeries.
> > > > We are implementing this function like that:
> > > > 
> > > >   <mx:PlotSeries name="Company1" xField="Debt_1" 
> yField="Cds_1"/>
> > > >   <mx:PlotSeries name="Company2" xField="Debt_2" 
> yField="Cds_2"/>
> > > >   <mx:PlotSeries name="Company3" xField="Debt_3" 
> yField="Cds_3"/>
> > > >   ...
> > > > 
> > > > but it cannot get data from backgroud dynamically. If we put 
all
> > > company
> > > > infomation into same Array, there would be no different color 
> and
> > > shape.
> > > > 
> > > > Thanks in advance!
> > > > John
> > > > 
> > > > 
> > > > 
> > > > 
> > > > 
> > > > --
> > > > Flexcoders Mailing List
> > > > FAQ: 
> > > http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
> > > > Search Archives:
> > > > http://www.mail-archive.com/flexcoders%40yahoogroups.com
> > > > Yahoo! Groups Links
> > > >
> > > 
> > > 
> > > 
> > > 
> > > 
> > > 
> > > --
> > > Flexcoders Mailing List
> > > FAQ: 
> > http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
> > > Search Archives:
> > > http://www.mail-archive.com/flexcoders%40yahoogroups.com
> > > Yahoo! Groups Links
> > >
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > --
> > Flexcoders Mailing List
> > FAQ: 
> http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
> > Search Archives:
> > http://www.mail-archive.com/flexcoders%40yahoogroups.com
> > Yahoo! Groups Links
> >
>






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

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/flexcoders/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



Reply via email to