0

Am Creating a dynamic apex chart .The problem am facing is in calculating the maximum value is considering only 500.00 where in the map has still higher values . Thanks for help in advance.

The Flollowing Code is For Reference

<apex:page controller="ApexChartTest" action="{!BuildChartData}">
 <script>
            var dataAcc = new Array();
                    <apex:repeat value="{!ChartData}" var="a">
            var dataArray = {};
                    dataArray['Fyname'] = '2015';
            <apex:repeat value="{!ChartData[a]}" var="cmap">

            dataArray['{!cmap}'] = '{!ChartData[a][cmap]}';
            console.log('{!cmap} {!ChartData[a][cmap]}');
            </apex:repeat>
            dataAcc.push(dataArray);

            </apex:repeat>
</script>
             <apex:chart height="400" width="900" data="dataAcc">
                 <apex:legend position="right"/>
                                 <apex:axis type="Numeric" position="left" fields="{!yfields}" title="Test Chart"  grid="true" minimum="0" />
                                <apex:axis type="Category" position="bottom" fields="Fyname" title="TestChart" >
                                      <apex:chartLabel rotate="0"/>
                                </apex:axis>
                                 <apex:barSeries title="{!yfields}" orientation="vertical" axis="left" tips="false" colorsProgressWithinSeries="true" xField="Fyname" yField="{!yfields}" >
                                       <apex:chartTips height="50" width="150" labelField="Fyname" valueField="{!yfields}" />
                                    </apex:barSeries>
                                 </apex:chart>
</apex:page>

/Controller/

public class ApexChartTest {
public string yfields                                  { get; set; }
public Map<String,Map<String,Decimal>> ChartData       { get; set; }

public void BuildChartData(){
    ChartData = new Map<String,Map<String,decimal>>();
    Map<String,decimal> tempmap = new  Map<String,decimal>();

    tempmap.put('IE',1255.00);    
    tempmap.put('RE',10000.00);
    tempmap.put('Gross Sales',13500.00); 
    tempmap.put('Sales Return',1000.00);
    tempmap.put('Net Sales',12500.00);
    tempmap.put('Depriciation Expense',500.00);
    ChartData.put('2015',tempmap);
    yfields = 'IE,RE,Gross Sales,Sales Return,Net Sales,Depriciation Expense';

   }
}
  • Can you explain in more detail what you mean by "considering only 500.00 where in the map has still higher values"? – Keith C Mar 4 '16 at 9:59
0

Hi the Following changes need to be made to script tag. i.e..,parseFloat()/parseInt() to parse the value coming from controller.

 <script>
            var dataAcc = new Array();
                    <apex:repeat value="{!ChartData}" var="a">
            var dataArray = {};
                    dataArray['Fyname'] = '2015';
            <apex:repeat value="{!ChartData[a]}" var="cmap">

            dataArray['{!cmap}'] = pasreFloat('{!ChartData[a][cmap]}');
            console.log('{!cmap} {!ChartData[a][cmap]}');
            </apex:repeat>
            dataAcc.push(dataArray);

            </apex:repeat>
</script>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.