I'm using the following AdvancedDataGrid control in my flex application:
<mx:AdvancedDataGrid id="tableDataGrid" height="95%" editable="false" dataProvider="{tableDataGridLst}"
sortableColumns="true" draggableColumns="false" resizableColumns="true" headerStyleName="adgHeaderStyle"
textAlign="center" headerWordWrap="true" verticalScrollPolicy="on" headerHeight="50"
rowCount="{tableDataGridLst.length + 2}" >
<mx:columns>
<mx:AdvancedDataGridColumn headerText="Actual Hours Iet" dataField="actualhoursIet" dataTipField="actualhoursIet"
width="60" textAlign="left" headerWordWrap="true" fontSize="11" showDataTips="true" />
<mx:AdvancedDataGridColumn headerText="Actual Imp Iet" dataField="actualIet" dataTipField="actualIet"
width="60" textAlign="left" headerWordWrap="true" fontSize="11" showDataTips="true" />
<mx:AdvancedDataGridColumn headerText="Actual Hours 3PGH" dataField="actualhours3pgh" dataTipField="actualhours3pgh"
width="60" textAlign="left" headerWordWrap="true" fontSize="11" showDataTips="true" />
<mx:AdvancedDataGridColumn headerText="Actual Imp 3PGH" dataField="actual3pgh" dataTipField="actual3pgh"
width="60" textAlign="left" headerWordWrap="true" fontSize="11" showDataTips="true" />
<mx:AdvancedDataGridColumn headerText="Actual Hours RH" dataField="actualhoursrh" dataTipField="actualhoursrh"
width="60" textAlign="left" headerWordWrap="true" fontSize="11" showDataTips="true" />
<mx:AdvancedDataGridColumn headerText="Actual Imp RH" dataField="actualrh" dataTipField="actualrh"
width="60" textAlign="left" headerWordWrap="true" fontSize="11" showDataTips="true" />
<mx:AdvancedDataGridColumn headerText="EMD AS" dataField="asValue" dataTipField="asValue"
width="60" textAlign="left" headerWordWrap="true" fontSize="11" showDataTips="true" />
<mx:AdvancedDataGridColumn headerText="EMD TN" dataField="tnValue" dataTipField="tnValue"
width="60" textAlign="left" headerWordWrap="true" fontSize="11" showDataTips="true" />
<mx:AdvancedDataGridColumn headerText="Year" dataField="year" dataTipField="year"
width="60" textAlign="left" headerWordWrap="true" fontSize="11" showDataTips="true" />
<mx:AdvancedDataGridColumn headerText="Month(AS)" dataField="monthAS" dataTipField="monthAS"
width="60" textAlign="left" headerWordWrap="true" fontSize="11" showDataTips="true" />
<mx:AdvancedDataGridColumn headerText="No of Act(AS)" dataField="noOfActASCost" dataTipField="noOfActASCost"
width="60" textAlign="left" headerWordWrap="true" fontSize="11" showDataTips="true" />
<!--<mx:AdvancedDataGridColumn headerText="Total Hours(AS) " dataField="hoursAS" dataTipField="hoursAS"
width="150" textAlign="left" headerWordWrap="true" fontSize="11" showDataTips="true" />
--><mx:AdvancedDataGridColumn headerText="Month(TN)" dataField="monthTN" dataTipField="monthTN"
width="60" textAlign="left" headerWordWrap="true" fontSize="11" showDataTips="true" />
<mx:AdvancedDataGridColumn headerText="No of Act(TN)" dataField="noOfActTNCost" dataTipField="noOfActTNCost"
width="60" textAlign="left" headerWordWrap="true" fontSize="11" showDataTips="true" />
<mx:AdvancedDataGridColumn headerText="Total Hours(1S/1F/1B)(TN)" dataField="hoursTN" dataTipField="hoursTN"
width="60" textAlign="left" headerWordWrap="true" fontSize="11" showDataTips="true" />
<mx:AdvancedDataGridColumn headerText="Status Tracking(TN)" dataField="statusTracking" dataTipField="statusTracking"
width="60" textAlign="left" headerWordWrap="true" fontSize="11" showDataTips="true" />
<mx:AdvancedDataGridColumn headerText="BAU(TN)" dataField="BAU" dataTipField="BAU"
width="60" textAlign="left" headerWordWrap="true" fontSize="11" showDataTips="true" />
</mx:columns>
</mx:AdvancedDataGrid>
basically, I'm getting the data from dataProvider tableDataGridList and the values are basically decimals, displayed as strings over the bar chart columns:
All I want to do is to truncate these decimal values to int values(like 100.56 to 100) and then display them. How can I do so?
You need to define chart dataTipFunction to resolve this issue.
chartInstance.dataTipFunction = myDataTipFunction
private function myDataTipFunction(hd:HitData):String
{
return hd.item.label + "\n " + Math.round(parseInt(hd.item.y));
}
In place of "hd.item.y" you need to update your variable like "hd.item.yourVariable".
By this way you can customize you data Tip for chart.
Hope this will work for you.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.