Use the updateDataChild() method to add a label to a single data point on the line : Label Data « Components « Flex

Home
Flex
1.Chart
2.Components
3.Container
4.Data Model
5.Development
6.Effects
7.Event
8.Graphics
9.Grid
10.Style
Flex » Components » Label DataScreenshots 
Use the updateDataChild() method to add a label to a single data point on the line
Use the updateDataChild() method to add a label to a single data point on the line
           

<!--
Code from Flex 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 
  (1proper attribution to Adobe is given as the owner of the user guide; and 
  (2any 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/UpdateDataChildExample.mxml -->
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
    xmlns:mx="library://ns.adobe.com/flex/mx" xmlns:s="library://ns.adobe.com/flex/spark"
    height="600">
    <fx:Script> 
        import mx.controls.Label; 
        import mx.charts.chartClasses.CartesianCanvasValue; 
        import mx.collections.ArrayCollection; 
        [Bindable
        public var expenses:ArrayCollection = new ArrayCollection([ 
            {Month:"Jan", Profit:2000, Expenses:1500, Amount:450}
            {Month:"Feb", Profit:1000, Expenses:200, Amount:600}
            {Month:"Mar", Profit:1500, Expenses:500, Amount:300
            ])
        public function drawData():void 
        
            canvas.clear()
            canvas.beginFill(0xFF00331)
            canvas.drawCircle("Feb"100020)
            canvas.endFill()
            var myLabel:Label = new Label()
            myLabel.text = "X"
            myLabel.setStyle("fontWeight""bold")
            myLabel.setStyle("fontSize"20)
            canvas.addChild(myLabel)
            canvas.updateDataChild(myLabel, "Feb"1100)
        
      </fx:Script>
    <s:layout>
        <s:VerticalLayout />
    </s:layout>
    <s:Panel title="Line Chart">
        <s:layout>
            <s:HorizontalLayout />
        </s:layout>
        <mx:LineChart id="myChart" dataProvider="{expenses}"
            showDataTips="true" creationComplete="drawData()">
            <mx:annotationElements>
                <mx:CartesianDataCanvas id="canvas"
                    includeInRanges="true" />
            </mx:annotationElements>
            <mx:horizontalAxis>
                <mx:CategoryAxis dataProvider="{expenses}"
                    categoryField="Month" />
            </mx:horizontalAxis>
            <mx:series>
                <mx:LineSeries yField="Profit" displayName="Profit" />
                <mx:LineSeries yField="Expenses" displayName="Expenses" />
            </mx:series>
        </mx:LineChart>
        <mx:Legend dataProvider="{myChart}" />
    </s:Panel>
</s:Application>

   
    
    
    
    
    
    
    
    
    
    
  
Related examples in the same category
1.Define Data Model in Model tag and use it with LabelDefine Data Model in Model tag and use it with Label
2.Bind Data Model to LabelBind Data Model to Label
3.Use categoryField property to point to the field in the data provider that contains the labels for the axisUse categoryField property to point to the field in the data provider that contains the labels for the axis
4.Generates data labels for a PieSeries object that include data and formattingGenerates data labels for a PieSeries object that include data and formatting
5.Add an axis solely for the purpose of adding the label to the DataTipAdd an axis solely for the purpose of adding the label to the DataTip
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.