Define a custom component inline by using the tag. : Column Chart Style « Chart « Flex






Define a custom component inline by using the tag.

Define a custom component inline by using the <fx:Component> tag.
               

<!--
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/LabelRendererWithToolTips.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"
    initialize="setupDP()" width="550" height="600">
    <fx:Script> 
         
        import mx.collections.ArrayCollection; 
        import mx.charts.ColumnChart; 
        [Bindable] 
        private var ac:ArrayCollection; 
        public function setupDP():void{ 
            ac = new ArrayCollection([ 
                [ "Label 1 is short.", 200000], 
                [ "Label 2 is a fairly long label.", 150000], 
                [ "Label 3 is an extremely long label. It contains 95 characters and will likely be truncated.", 40000] 
        ]); 
        } 
      
    </fx:Script>
    <s:layout>
        <s:VerticalLayout />
    </s:layout>
    <s:Panel title="Column Chart">
        <s:layout>
            <s:VerticalLayout />
        </s:layout>
        <mx:ColumnChart id="bc1" showDataTips="true"
            dataProvider="{ac}">
            <mx:series>
                <mx:ColumnSeries xField="0" yField="1" />
            </mx:series>
            <mx:verticalAxis>
                <mx:LinearAxis id="va1" />
            </mx:verticalAxis>
            <mx:horizontalAxis>
                <mx:CategoryAxis id="ha1" dataProvider="{ac}"
                    categoryField="0" />
            </mx:horizontalAxis>
            <mx:horizontalAxisRenderers>
                <mx:AxisRenderer axis="{ha1}" canDropLabels="false">
                    <mx:labelRenderer>
                        <fx:Component>
                            <mx:Label toolTip="{this.myTip}">
                                <fx:Script> 
                                    [Bindable] 
                                    private var myTip:String; 
                                    override public function set data(value:Object):void{ 
                                        if(value == null) 
                                            return; 
                                            myTip = value.text; 
                                            var length:int = value.text.toString().length; 
                                            if (length > 20) { 
                                                text = value.text.toString().substr(0, 20) + "..."; 
                                            } else { 
                                                text = value.text; 
                                            } 
                                    } 
                                  </fx:Script>
                            </mx:Label>
                        </fx:Component>
                    </mx:labelRenderer>
                </mx:AxisRenderer>
            </mx:horizontalAxisRenderers>
            <mx:verticalAxisRenderers>
                <mx:AxisRenderer axis="{va1}" canDropLabels="false" />
            </mx:verticalAxisRenderers>
        </mx:ColumnChart>
        <s:Label id="l1" color="white"
            text="Hover over the horizontal axis's labels to see the entire title rendered as a ToolTip." />
    </s:Panel>
</s:Application>

   
    
    
    
    
    
    
    
    
    
    
    
    
    
    
  








Related examples in the same category

1.ColumnChart with Color GradientColumnChart with Color Gradient
2.Use SolidColorStoke to paint horizontalStrokeUse SolidColorStoke to paint horizontalStroke
3.Use SolidColorStoke to paint verticalStrokeUse SolidColorStoke to paint verticalStroke
4.Set fill colorSet fill color
5.background Elements for ColumnChartbackground Elements for ColumnChart
6.Remove Shadows for ColumnChartRemove Shadows for ColumnChart
7.Fill column with LinearGradientFill column with LinearGradient
8.Use GridLines as backgroundUse GridLines as background
9.LinearGradient fillLinearGradient fill
10.Formatting grid lines with ActionScriptFormatting grid lines with ActionScript
11.Formatting grid lines with MXMLFormatting grid lines with MXML
12.Chart With StyleChart With Style
13.Apply a custom drop shadow filter to a ColumnChart controlApply a custom drop shadow filter to a ColumnChart control
14.Creates a floating ColumnChart controlCreates a floating ColumnChart control
15.Alternatively, you can set the gutter properties inlineAlternatively, you can set the gutter properties inline
16.specify the x, y, height, and width properties of a rectangular range.specify the x, y, height, and width properties of a rectangular range.
17.Add background to chartAdd background to chart
18.Add new grid lines as annotation elements to the chart and an image as the background element.Add new grid lines as annotation elements to the chart and an image as the background element.
19.Add an image to the chart and manipulate its propertiessAdd an image to the chart and manipulate its propertiess
20.Style tickStrokeStyle tickStroke
21.Style minorTickStrokeStyle minorTickStroke
22.Disabling axis labelsDisabling axis labels
23.Change the label alignment for the vertical and horizontal axes.Change the label alignment for the vertical and horizontal axes.