0 Replies Latest reply on Feb 28, 2009 5:46 PM by kemah551

    Chart data binding

    kemah551
      Hi

      I'm trying to bind a label's value to a chart in an ArrayCollection. One value will be fixed while the second value is provided by the results of a label.

      Here's my code:

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute" xmlns:ns1="com.fusioncharts.components.*" viewSourceURL="srcview/index.html">


      <mx:Script>
      <![CDATA[
      import mx.collections.ArrayCollection;
      import mx.formatters.NumberBaseRoundType;



      ]]>
      </mx:Script>

      <mx:ArrayCollection id="format" />

      <mx:NumberFormatter id="numberFormatter"
      precision="2"
      rounding="up" />




      <mx:VBox paddingTop="10" height="536" width="708">
      <mx:Text paddingLeft="15" text="Default Rate Analyzer" fontSize="14" fontWeight="bold" color="#FFFFFF"/>
      <mx:HBox paddingTop="10" paddingLeft="10">
      <mx:VBox>
      <mx:Panel title="Spread Numbers between Treasuries and Bond type:" height="105">



      <mx:Form id="myForm1" width="350" paddingTop="10" height="65">
      <mx:HBox>
      <mx:HSlider id="mySlider" snapInterval=".01" maximum="30" showDataTip="true" liveDragging="true" width="234" tickInterval="10" borderColor="#66658a" minimum="0" value="16.79" labels="[0%,10%,20%,30%]" visible="true">
      </mx:HSlider>
      <mx:NumericStepper id="stepper" stepSize=".01" value="{mySlider.value}" maximum="3000" minimum="0" minWidth="70" maxWidth="100" includeInLayout="true" toolTip="Increment number by .01%"/>
      </mx:HBox>
      </mx:Form>

      </mx:Panel>
      <mx:Panel title="Risk Premium:" height="117">
      <mx:Form id="myForm2" width="350" height="73" paddingTop="10">
      <mx:HBox height="41">


      <mx:HSlider id="mySlider2" snapInterval=".01" maximum="20" showDataTip="true" liveDragging="true" width="234" tickInterval="5" borderColor="#66658A" minimum="0" values="3.00" labels="[0%,5%,10%,15%,20%]"/>
      <mx:NumericStepper id="stepper2" stepSize=".01" value="{mySlider2.value}" maximum="50" minimum="0" minWidth="70" maxWidth="100" toolTip="Increment number by .01%"/>
      </mx:HBox>
      </mx:Form>
      </mx:Panel>
      <mx:Panel title="Calculate Current Spread (Less Risk Premium):">
      <mx:Form id="myForm3" width="350">
      <mx:FormItem label="Calculate Current Spread: " width="314">
      <mx:Label text="{numberFormatter.format(stepper.value-stepper2.value)+&apos;%&apos;}" selectable="false" maxWidth="150" minWidth="50" width="149" id="inputVal" textAlign="right"/>
      </mx:FormItem>
      </mx:Form>
      </mx:Panel>
      <mx:Panel title="Default Rate Loss:" width="368" height="109">

      <mx:HBox height="69" width="344" id="myForm5" paddingBottom="10" paddingTop="10" paddingLeft="15">

      <mx:HSlider id="mySlider0" snapInterval=".25" maximum="100" showDataTip="true" liveDragging="true" width="234" tickInterval="20" minimum="0" allowTrackClick="true" borderColor="#66658a" values="80.00" labels="[0%,20%,40%,60%,80%,100%]" height="42"/>
      <mx:NumericStepper id="stepper0" stepSize=".01" value="{mySlider0.value}" maximum="100" minimum="0.00" minWidth="70" maxWidth="100" toolTip="Increment number by .01%"/>

      </mx:HBox>


      </mx:Panel>
      </mx:VBox>
      <mx:VBox height="456">
      <mx:Panel title="Results: Calculated Implied Default Rate" width="264" height="106">
      <mx:VBox width="100%">
      <mx:HBox paddingTop="5" width="100%">
      </mx:HBox>
      <mx:HBox width="100%" paddingLeft="15">
      <mx:Label text="{numberFormatter.format((stepper.value-stepper2.value)/stepper0.value*(100))}%" maxWidth="120" minWidth="50" id="formats"/>
      </mx:HBox>
      </mx:VBox>


      </mx:Panel>
      <mx:Panel title="Chart" width="264" height="327">
      <ns1:FusionCharts x="434" y="36" FCChartType="Column3D" width="242" height="285" themeColor="#e6eaee">

      <ns1:FCChartData FCData="{chartData}" FCParams="{chartParams}" />

      </ns1:FusionCharts>





      <mx:Script>

      <![CDATA[


      import mx.collections.ArrayCollection;

      //Create an ArrayCollection object as a data source for chart

      [Bindable]

      private var chartData:ArrayCollection=new ArrayCollection([

      { label:'Great Depression', value:'15.4' },
      { label:'User Values', value: 'Label.formats' }
      ]);


      //Create an ArrayCollection object as a data source for chart

      [Bindable]



      private var chartData2:ArrayCollection=new ArrayCollection([

      { label:'Great Depression', value:'15.4' },
      { label:'User Values', value: '77' } //this is where I want to display the labels value (id=formats)
      ]);

      //Create an ArrayCollection object as a data source for chart parameters

      [Bindable]

      private var chartParams:ArrayCollection=new ArrayCollection([

      { caption:'Default Rate Chart' },
      { xAxisName:'Option adjusted spread (OAS)' },
      { yAxisName:'Default Rate' },
      { numberSuffix:'%25' }
      ]);

      ]]>

      </mx:Script>


      </mx:Panel>
      </mx:VBox>
      </mx:HBox>
      </mx:VBox>


      </mx:Application>