1

I need to plot values vs week. I don't see any errors. But just the data is not populated ?

public class ChartController {
    // Return a list of data points for a chart
    public List<Data> getData() {
        return ChartController.getChartData();
    }

    // Make the chart data available via JavaScript remoting
    @RemoteAction
    public static List<Data> getRemoteData() {
        return ChartController.getChartData();
    }

    // The actual chart data; needs to be static to be
    // called by a @RemoteAction method
    public static  List<Data> getChartData() {
        List<Data> data = new List<Data>();

        List<Onboard_Forecast__c>  ofList = [SELECT Actual__c,Week__c,Planned__c,Forecast__c FROM Forecast__c ];
        for(Forecast__c of1:ofList){

            data.add(new Data(string.valueof(of1.Week__c),integer.valueof(of1.Actual__c),integer.valueof(of1.Forecast__c),integer.valueof(of1.Planned__c)));
        }
        return data;


    }

    // Wrapper class
    public class Data {
        public String name { get; set; }
        public Integer data1 { get; set; }
        public Integer data2 { get; set; }
        public Integer data3 { get; set; }
        public Data(String name, Integer data1, Integer data2, Integer data3) {
            this.name = name;
            this.data1 = data1;
            this.data2 = data2;
            this.data3 = data3;
            system.debug('week '+this.name);
        }
    }
}
8
  • Does your query return everything? May 27, 2016 at 0:35
  • Yeah it returns 52 records.
    – Aravind
    May 27, 2016 at 5:42
  • 1
    Can open your page. Click right button and select inspect element. In your console log you should see visual force chart data. Do you see it? May 27, 2016 at 5:58
  • Got error message... "Visualforce Chart: Error loading configuration for chart 'jid0jid1': Did not find required field 'Week' in data for chart 'jid0jid1'. Make sure field was queried and/or provided and has a value."
    – Aravind
    May 27, 2016 at 6:02
  • I fixed that issue. Now I get error "login.salesforce.com/17181/logo180.png Failed to load resource: the server responded with a status of 404 (Not Found)"
    – Aravind
    May 27, 2016 at 16:21

1 Answer 1

0

I had to handle the Nullvalues. dataList.add(new Data(Integer.valueOf(of1.week__c),of1.Actual__c!=null?Integer.valueOf(of1.Actual__c):0,of1.Forecast__c!=null?Integer.valueOf(of1.Forecast__c):0,of1.Planned__c!=null?Integer.valueOf(of1.Planned__c):0));

You must log in to answer this question.

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