justmeadam
01-09-2007, 12:51 AM
Hey everyone, I am having a bit of trouble and for all I know I am making something too complicated.
I have a repeater that runs through an array where each object is a date and number.
The repeater works fine, but what I would LOVE to happen is when someone selects one of the radio buttons the "date and number" from that object / selected index gets passed to a column chart.
Ideally the chart would have one date / number and the 2nd date / number would come come from the radio buttons, this would be used for comparing two objects. One is static and that gets compared with the one you selected.
For now I have gotten rid of the chart and am just trying to pass the two items to a datagrid, I have gone through so many changes I am losing my mind ... not much to lose I know but any help would be appreciated!
<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
private var arrayData:Array=[
{date:"12-24-06", avg:"22"},
{date:"12-27-06", avg:"65"},
{date:"12-28-06", avg:"11"},
{date:"01-07-07", avg:"89"}];
[Bindable]
private var dp:ArrayCollection=new ArrayCollection(arrayData);
[Bindable]
public function displayData(repeaterItem : Object):void
{
averageLabel.text=repeaterItem.avg;
dateLabel.text=repeaterItem.date;
trace (repeaterItem.date);
}
]]>
</mx:Script>
<mx:Label id="averageLabel" text="Average"/><mx:Label id="dateLabel" text="Date"/>
<mx:Repeater id="myRepeater" dataProvider="{dp}">
<mx:RadioButton label="{myRepeater.currentItem.date}"
click="displayData(event.target.getRepeaterItem())" />
</mx:Repeater>
<mx:DataGrid id="test" dataProvider="{myRepeater.currentIndex}">
<mx:columns>
<mx:DataGridColumn headerText="Column 1" dataField="itemRepeater.date"/>
<mx:DataGridColumn headerText="Column 2" dataField="itemRepeater.avg"/>
</mx:columns>
</mx:DataGrid>
</mx:Application>
I have a repeater that runs through an array where each object is a date and number.
The repeater works fine, but what I would LOVE to happen is when someone selects one of the radio buttons the "date and number" from that object / selected index gets passed to a column chart.
Ideally the chart would have one date / number and the 2nd date / number would come come from the radio buttons, this would be used for comparing two objects. One is static and that gets compared with the one you selected.
For now I have gotten rid of the chart and am just trying to pass the two items to a datagrid, I have gone through so many changes I am losing my mind ... not much to lose I know but any help would be appreciated!
<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
private var arrayData:Array=[
{date:"12-24-06", avg:"22"},
{date:"12-27-06", avg:"65"},
{date:"12-28-06", avg:"11"},
{date:"01-07-07", avg:"89"}];
[Bindable]
private var dp:ArrayCollection=new ArrayCollection(arrayData);
[Bindable]
public function displayData(repeaterItem : Object):void
{
averageLabel.text=repeaterItem.avg;
dateLabel.text=repeaterItem.date;
trace (repeaterItem.date);
}
]]>
</mx:Script>
<mx:Label id="averageLabel" text="Average"/><mx:Label id="dateLabel" text="Date"/>
<mx:Repeater id="myRepeater" dataProvider="{dp}">
<mx:RadioButton label="{myRepeater.currentItem.date}"
click="displayData(event.target.getRepeaterItem())" />
</mx:Repeater>
<mx:DataGrid id="test" dataProvider="{myRepeater.currentIndex}">
<mx:columns>
<mx:DataGridColumn headerText="Column 1" dataField="itemRepeater.date"/>
<mx:DataGridColumn headerText="Column 2" dataField="itemRepeater.avg"/>
</mx:columns>
</mx:DataGrid>
</mx:Application>