function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Sreenivasulu AdipudiSreenivasulu Adipudi 

Error on dynamic visualforce stack graph

Hi everyone,

I created a stack graph with a visualforce page and some javascript.
I am not familiar with Javascript. I am getting the following error.
"Unknown property 'AccountStandardController.data'".

Visualforce Page:
<apex:page standardController="Account" extensions="DashboardExtn ">
<script>
    // Build the chart data array in JavaScript
    var data = new Array();
</script>

<apex:repeat value="{!data}" var="monthList">
    <script type="text/javascript">
    var product = {};
    </script>
    <apex:repeat value="{!data[monthList]}" var="productList">
        {!monthList} {!productList} {!data[monthList][productList]}<br/>
        <script type="text/javascript">
            product['{!productList}'] = {!data[monthList][productList]};
            product['name'] = '{!monthList}';
        </script>
    </apex:repeat>
<script type="text/javascript">
data.push(product);
</script>
</apex:repeat>
    
    <apex:chart data="data" height="400" width="500">
    <apex:legend position="left"/>
    <apex:axis type="Numeric" position="left" title="title" grid="true" fields="yfield" dashSize="2">
        <apex:chartLabel />
    </apex:axis>
    <apex:axis type="Category" position="bottom" fields="name">
        <apex:chartLabel rotate="315"/>
    </apex:axis>
    <apex:barSeries orientation="vertical" axis="left" stacked="true" xField="name" yField="yfield" title="title"/>
</apex:chart>
</apex:page>

Controller :
public class DashboardExtn 
{
    public static ID accountID;
    public static Map<String, Map<String,Decimal>> data;
    
    public DashboardExtn(ApexPages.StandardController controller)
    {
        accountID = controller.getId();
    }

    public static Map<String, Map<String,Decimal>> getChartData() 
    {
        data = new Map<String, Map<String,Integer>>();
        for (Account objAccount : [SELECT Id, Name, Status__c, Access_Percentage__c FROM Account WHERE Id =: accountID]) 
        {
            putData(objAccount.Name, objAccount.Access_Percentage__c, objAccount.Status__c);
        }
        return data;
    }
 
    private static void putData(String Name, Decimal accessPercentage, String status){
    Map<String,Decimal> statusGroup = new Map<String,Decimal>();
    if (data.containsKey(Name)){
        statusGroup = data.get(Name);
    }
    statusGroup.put(status, accessPercentage);
    data.put(Name, statusGroup);
}

Can anyone please help me in this query.
Best Answer chosen by Sreenivasulu Adipudi
Raj VakatiRaj Vakati
You have to use the get and set  .. please use this code
 
public class DashboardExtn 
{
    public static ID accountID;
    public static Map<String, Map<String,Decimal>> data{get;set;}
    
    public DashboardExtn(ApexPages.StandardController controller)
    {
        accountID = controller.getId();
getChartData();
    }

    public static Map<String, Map<String,Decimal>> getChartData() 
    {
        data = new Map<String, Map<String,Integer>>();
        for (Account objAccount : [SELECT Id, Name, Status__c, Access_Percentage__c FROM Account WHERE Id =: accountID]) 
        {
            putData(objAccount.Name, objAccount.Access_Percentage__c, objAccount.Status__c);
        }
        return data;
    }
 
    private static void putData(String Name, Decimal accessPercentage, String status){
    Map<String,Decimal> statusGroup = new Map<String,Decimal>();
    if (data.containsKey(Name)){
        statusGroup = data.get(Name);
    }
    statusGroup.put(status, accessPercentage);
    data.put(Name, statusGroup);
}