2 Replies Latest reply on Oct 19, 2010 11:24 PM by bindu84

    alignment issue

    bindu84 Level 1

      how to align datalabel to center in bar and column chart if labelPosition is outside

       

       

       

      <!-- charts/BasicDataLabel.mxml -->

      <mx:Application

       

       

      xmlns:mx="http://www.adobe.com/2006/mxml" initialize="setStartLabelLocation()">

       

      <mx:Script><![CDATA[

       

      import mx.collections.ArrayCollection;

       

      [

      Bindable]

       

      public var expenses:ArrayCollection = new ArrayCollection([

      {Month:

      "Jan", Income:2000, Expenses:1500},

      {Month:

      "Feb", Income:1000, Expenses:20},

      {Month:

      "Mar", Income:1500, Expenses:50}

      ]);

       

       

      private function setStartLabelLocation():void {

      cs1.setStyle(

      "labelPosition", "outside");

      cs2.setStyle(

      "labelPosition", "outside");

      }

       

       

      ]]>

      </mx:Script>

       

       

      <mx:Panel title="Column Chart">

       

      <mx:ColumnChart id="myChart"

      dataProvider="

      {expenses}"

      showDataTips="

      true"

       

      >

       

      <mx:horizontalAxis>

       

      <mx:CategoryAxis

      dataProvider="

      {expenses}"

      categoryField="

      Month"

       

      />

       

      </mx:horizontalAxis>

       

       

      <mx:verticalAxis>

       

      <mx:LinearAxis minimum="0" maximum="2500"/>

       

      </mx:verticalAxis>

       

       

      <mx:series>

       

      <mx:ColumnSeries

      id="

      cs1"

      xField="

      Month"

      yField="

      Income"

      displayName="

      Income"

       

      />

       

      <mx:ColumnSeries

      id="

      cs2"

      xField="

      Month"

      yField="

      Expenses"

      displayName="

      Expenses"

       

      />

       

      </mx:series>

       

      </mx:ColumnChart>

       

      <mx:Legend dataProvider="{myChart}"/>

       

      </mx:Panel>

       

       

      </mx:Application>