Enable data labels on the columns by setting the value of the labelPosition style property to inside : Label Style « Components « Flex






Enable data labels on the columns by setting the value of the labelPosition style property to inside

Enable data labels on the columns by setting the value of the labelPosition style property to inside
           

<!--
Code from Flex 4 Documentation "Using Adobe Flex 4".

This user guide is licensed for use under the terms of the Creative Commons Attribution 
Non-Commercial 3.0 License. 

This License allows users to copy, distribute, and transmit the user guide for noncommercial 
purposes only so long as 
  (1) proper attribution to Adobe is given as the owner of the user guide; and 
  (2) any reuse or distribution of the user guide contains a notice that use of the user guide is governed by these terms. 
The best way to provide notice is to include the following link. 
To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/3.0/

-->
<!-- charts/BasicDataLabel.mxml -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
    initialize="setStartLabelLocation()">
    <mx:Script>
        import mx.collections.ArrayCollection;
        [Bindable]
        public var expenses:ArrayCollection = new ArrayCollection([
            {Month:"Jan", Income:2000, Expenses:1500},
            {Month:"Feb", Income:1000, Expenses:200},
            {Month:"Mar", Income:1500, Expenses:500}
            ]);
        private function setStartLabelLocation():void {
            cs1.setStyle("labelPosition", "inside");
            cs2.setStyle("labelPosition", "inside");
        }
        private function changeLabelLocation():void {
            var pos:String = cs1.getStyle("labelPosition");
            if (pos == "inside") {
                pos = "outside";
            } else {
                pos = "inside";
            }
            cs1.setStyle("labelPosition", pos);
            cs2.setStyle("labelPosition", pos);
        }
      </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:Button id="b1" label="Change Label Location"
            click="changeLabelLocation()" />
    </mx:Panel>
</mx:Application>

   
    
    
    
    
    
    
    
    
    
    
  








Related examples in the same category

1.Apply style to LabelApply style to Label
2.Label style
3.Set style name for LabelSet style name for Label
4.Set Text, font weight and font size for LabelSet Text, font weight and font size for Label
5.Set font weight and size for LabelSet font weight and size for Label
6.The following example embeds a font and rotates the data labels 45 degrees:The following example embeds a font and rotates the data labels 45 degrees:
7.Overwrite Label font size with attribute
8.Name appears in the DataTip in italic font before the label dataName appears in the DataTip in italic font before the label data