0

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: Decimal data displayed as DataTip

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?

ketan
  • 19,129
  • 42
  • 60
  • 98
Ruchir Sharma
  • 819
  • 1
  • 10
  • 18

1 Answers1

1

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.

Randhir Kumar
  • 197
  • 10
  • Thanks for the reply sir. Actually I'm quite new to flex. So where should I write this code? In the beginning of my .mxml file ? – Ruchir Sharma Aug 11 '15 at 12:12
  • You should place this code on the same file where you have instantiate the chart component. If it is in mxml file place within the script block or if it is in Actionscript file(.as) file place first line where you have instantiate the chart component and place myDataTipFunction() function anywhere in the same class. – Randhir Kumar Aug 12 '15 at 04:09