Archive for January, 2009
January 18th, 2009
This component extends the default Legend component and adds to it few item highlighting related features. It works with all chart types and clicking on a legend item will lead to its visibility being toggled. Furthermore mouse over legend item leads to reduction of alphas of other chart series except the related chart series of the legend item on which the mouse is over.
Code:
<visualization:AdvancedLegend dataProvider="{lineChart}"/>
Screenshot:

What’s next?
– Checkboxes based selectable legend items
– Chart series item style controls via legend
Demo | Source code
January 18th, 2009
This component extends the default TitleWindow component and add two very useful features which make the container resize able and movable. The AdvancedTitleWindow can be moved using the mouse drag on the titleBar and it can be resized using the mouse drag on the bottom right region.
Code:
<containers:AdvancedTitleWindow width="400" height="300"/>
Screenshot:

What’s next?
– Docking
– Minimize, Maximize options
– Selectable style patterns
Demo | Source code
January 4th, 2009
This version (0.1) of the DashedLineSeries component is an extension and implementation of the wonderful code posted on Quietly Scheming by Ely Greensfield. The component is an extension of a regular LineSeries except that it has a custom LineSeriesRenderer that draws a dashed line instead of a straight line.
Screen shot:
Code:
<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:visualization="net.srirangan.visualization.*">
<mx:Script><![CDATA[
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}
]);]]></mx:Script>
<mx:Panel title="Line Chart With Strokes">
<mx:LineChart id="myChart" dataProvider="{expenses}" showDataTips="true" seriesFilters="{new Array}">
<mx:horizontalAxis>
<mx:CategoryAxis dataProvider="{expenses}" categoryField="Month"/>
</mx:horizontalAxis>
<mx:series>
<visualization:DashedLineSeries yField="Profit" displayName="Profit"/>
<mx:LineSeries yField="Expenses" displayName="Expenses"/>
<mx:LineSeries yField="Amount" displayName="Amount"/>
</mx:series>
</mx:LineChart>
<mx:Legend dataProvider="{myChart}" direction="horizontal"/>
</mx:Panel>
</mx:Application>
What’s next?
– Pre defined multiple line patterns
– User defined line patterns
Demo | Source code
January 1st, 2009
Another useful code sample (originally posted on Experts-Exchange.com by yours truly) that allows CheckBox’s to be part of a DataGrid. This is accomplished is by setting the itemRenderer of a DataGridColumn to be a CheckBox and handling the selected and click properties of the CheckBox.
Note: It is important to set the DataGridColumn’s editable property to false as the itemRenderer itself is the itemEditor.

Code:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" horizontalAlign="center" verticalAlign="middle">
<mx:DataGrid id="dataGrid" editable="true">
<mx:dataProvider>
<mx:XMLList xmlns="">
<node isTrue="true" name="xxxxxxxx" location="yyyyyyy"/>
<node isTrue="false" name="xxxxxxxx" location="yyyyyyy"/>
<node isTrue="true" name="xxxxxxxx" location="yyyyyyy"/>
<node isTrue="false" name="xxxxxxxx" location="yyyyyyy"/>
<node isTrue="true" name="xxxxxxxx" location="yyyyyyy"/>
</mx:XMLList>
</mx:dataProvider>
<mx:columns>
<mx:DataGridColumn dataField="@isTrue" width="25" headerText=" " editable="false">
<mx:itemRenderer>
<mx:Component>
<mx:CheckBox selected="{(data.@isTrue == 'true')?true:false}" click="{data.@isTrue = (data.@isTrue != 'true') ? 'true' : 'false';}"/>
</mx:Component>
</mx:itemRenderer>
</mx:DataGridColumn>
<mx:DataGridColumn dataField="@name" headerText="Name"/>
<mx:DataGridColumn dataField="@location" headerText="Location"/>
</mx:columns>
</mx:DataGrid>
<mx:DataGrid dataProvider="{dataGrid.dataProvider}"/>
</mx:Application>
January 1st, 2009
Here’s a code sample I provided for a question posted on Experts Exchange. The asker wanted a static text tooltip for a particular column in a data grid. The code below uses the dataTipFunction to provide for the same.
Screenshot

Code
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical">
<mx:Script>
<![CDATA[
public function customDataTip(item:Object):String {
return "custom static data tip";
}
]]>
</mx:Script>
<mx:DataGrid>
<mx:columns>
<mx:DataGridColumn headerText="Name" dataField="@name"/>
<mx:DataGridColumn headerText="Age" dataField="@age"/>
<mx:DataGridColumn headerText="Location" dataField="@location" dataTipFunction="customDataTip" showDataTips="true"/>
</mx:columns>
<mx:dataProvider>
<mx:XMLList xmlns="">
<node name="AAA" age="1" location="New Delhi"/>
<node name="BBB" age="2" location="New Delhi"/>
<node name="CCC" age="3" location="New Delhi"/>
</mx:XMLList>
</mx:dataProvider>
</mx:DataGrid>
</mx:Application>