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';

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

1 Answer 1

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>

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .