• Ankur_Tyagi.ax1759
  • NEWBIE
  • 0 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 5
    Replies

Hi All,

 

I am using some highchart.js file to plot a graph on visualforce page, if i use hard code value to graph in js code then it is working fine but, if i use VF remoting to bring data from apex controller to plot graph, VF remoating bringing data from apex controler but jquery not ploting graph at all.

I am pasting my VF page code. Please help me on this...

 

VF page code:

 

<apex:page controller="ChartController">

    <apex:includeScript value="{!URLFOR($Resource.jQuery)}"/>
    <apex:includeScript value="{!URLFOR($Resource.HighChartJS, '/js/highcharts.js')}"/>
    <apex:includeScript value="{!URLFOR($Resource.HighChartJS, '/js/modules/exporting.js')}"/>
    <script type="text/javascript">
            var accountNames = [];
            var optNums = [];
            var optProbs = [];
            $(function() {
                
                 //VF remoating start
                Visualforce.remoting.Manager.invokeAction(
                    '{!$RemoteAction.ChartController.getRemoteData}',
                    function(result, event){
                        if (event.status) {
                        
                            for(var i=0; i<result.length; i++)
                            {
                                accountNames.push(result[i].name);
                                optNums.push(result[i].data1);
                                optProbs.push(result[i].data2);
                            }
                            
                            alert(accountNames);
                        } 
                        else {
                            //document.getElementById("responseErrors").innerHTML = event.message;
                            alert(event.message);
                        }
                    }, 
                    {escape: true}
                );
            
                //VF remoating end
            });
            $.when.apply($, accountNames).done(function() {
                
                $('#container').highcharts({
                    chart: {
                        type: 'line'
                    },
                    title: {
                        text: 'Monthly Average Temperature'
                    },
                    subtitle: {
                        text: 'Source: WorldClimate.com'
                    },
                    xAxis: {
                        categories: accountNames
                        //categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
                    },
                    yAxis: {
                        title: {
                            text: 'Temperature (°C)'
                        }
                    },
                    tooltip: {
                        enabled: false,
                        formatter: function() {
                            return '<b>'+ this.series.name +'</b><br/>'+
                                this.x +': '+ this.y +'°C';
                        }
                    },
                    plotOptions: {
                        line: {
                            dataLabels: {
                                enabled: true
                            },
                            enableMouseTracking: false
                        }
                    },
                    series: [{
                        name: 'Tokyo',
                        //data&colon; optNums
                        data&colon; [7.0, 6.9, 9.5, 14.5, 18.4, 21.5, 25.2, 26.5, 23.3, 18.3, 13.9, 9.6]
                    }, {
                        name: 'London',
                        //data&colon; optProbs
                        data&colon; [3.9, 4.2, 5.7, 8.5, 11.9, 15.2, 17.0, 16.6, 14.2, 10.3, 6.6, 4.8] 
                    }]
                });
            });
<table width="100%">
    <tr>
 <td width="50%">
     <div id="container" style="width: 500px; height: 500px;"></div>
 </td>
    </tr>
</table>
</apex:page>

 

 

Hello all. First time poster here who has relied heavily on these forums to learn Apex. Thank you!

 

Here's a problem that I hope might generate some discussion.

 

My goal was to take a list of Opportunities and group them by Account, not using a group by clause, rather, creating a list of lists such that each sublist contains opportunities for a unique AccountID. Given a list of opportunities (Opp1...Opp5), the end result should look something like this:

 

AccountA:

   Opp1

   Opp2

AccountB:

   Opp2

   Opp3

   Opp4

AccountC:

   Opp5

 

My first attempted solution is as follows where opps is passed as the function parameter. I had hoped this would return a list of Accounts with the relevant Opportunities in the relationship, but it did not work. The Account list is created as expected but the Opportunities relationship is empty.

 

 

Set<Id> addressees = new Set<Id>();
for(Opportunity o:opps){
  addressees.add(o.Id);
}
List<Account> a = [Select Id, Name, (Select Id, Name, Amount, CloseDate, IsWon, CharitableReceipt__c From Account.Opportunities Where Opportunity.Id in:opps) From Account where Id in :addressees];
return a;

 

 

In the end, I solved the problem using a for loop but it is not as elegant as a single SOQL statement. I'm curious if my original solution is workable.

 

public List<List<Opportunity>> groupOpportunities(List<Opportunity> opps){
        
Set<Id> accts = new Set<Id>();
List<List<Opportunity>> groupedOpps = new List<List<Opportunity>>();
        
//create an account control sets
for(Opportunity o:opps){
   accts.add(o.AccountId);
}
        
//add a new opp list for each account in the control set
for(Id i:accts){
   List<Opportunity> tempOpps = new List<Opportunity>();
   for(Opportunity o:opps){
      if (o.AccountId == i){tempOpps.add(o);}
   }
   groupedOpps.add(tempOpps);
}
        
return groupedOpps;

}

 

Hi all, is there any way to send documents from salesforce to some FTP folder?

 

Actually there are 2 requirements. First, a report should be automatically converted into csv at the end of the month and Second, this csv file should be send to ftp folder or any other local folder?

 

Please advise how I can achieve this?

 

Thanks
Abhi

  • July 15, 2013
  • Like
  • 0

Hi All,

 

I am using some highchart.js file to plot a graph on visualforce page, if i use hard code value to graph in js code then it is working fine but, if i use VF remoting to bring data from apex controller to plot graph, VF remoating bringing data from apex controler but jquery not ploting graph at all.

I am pasting my VF page code. Please help me on this...

 

VF page code:

 

<apex:page controller="ChartController">

    <apex:includeScript value="{!URLFOR($Resource.jQuery)}"/>
    <apex:includeScript value="{!URLFOR($Resource.HighChartJS, '/js/highcharts.js')}"/>
    <apex:includeScript value="{!URLFOR($Resource.HighChartJS, '/js/modules/exporting.js')}"/>
    <script type="text/javascript">
            var accountNames = [];
            var optNums = [];
            var optProbs = [];
            $(function() {
                
                 //VF remoating start
                Visualforce.remoting.Manager.invokeAction(
                    '{!$RemoteAction.ChartController.getRemoteData}',
                    function(result, event){
                        if (event.status) {
                        
                            for(var i=0; i<result.length; i++)
                            {
                                accountNames.push(result[i].name);
                                optNums.push(result[i].data1);
                                optProbs.push(result[i].data2);
                            }
                            
                            alert(accountNames);
                        } 
                        else {
                            //document.getElementById("responseErrors").innerHTML = event.message;
                            alert(event.message);
                        }
                    }, 
                    {escape: true}
                );
            
                //VF remoating end
            });
            $.when.apply($, accountNames).done(function() {
                
                $('#container').highcharts({
                    chart: {
                        type: 'line'
                    },
                    title: {
                        text: 'Monthly Average Temperature'
                    },
                    subtitle: {
                        text: 'Source: WorldClimate.com'
                    },
                    xAxis: {
                        categories: accountNames
                        //categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
                    },
                    yAxis: {
                        title: {
                            text: 'Temperature (°C)'
                        }
                    },
                    tooltip: {
                        enabled: false,
                        formatter: function() {
                            return '<b>'+ this.series.name +'</b><br/>'+
                                this.x +': '+ this.y +'°C';
                        }
                    },
                    plotOptions: {
                        line: {
                            dataLabels: {
                                enabled: true
                            },
                            enableMouseTracking: false
                        }
                    },
                    series: [{
                        name: 'Tokyo',
                        //data&colon; optNums
                        data&colon; [7.0, 6.9, 9.5, 14.5, 18.4, 21.5, 25.2, 26.5, 23.3, 18.3, 13.9, 9.6]
                    }, {
                        name: 'London',
                        //data&colon; optProbs
                        data&colon; [3.9, 4.2, 5.7, 8.5, 11.9, 15.2, 17.0, 16.6, 14.2, 10.3, 6.6, 4.8] 
                    }]
                });
            });
<table width="100%">
    <tr>
 <td width="50%">
     <div id="container" style="width: 500px; height: 500px;"></div>
 </td>
    </tr>
</table>
</apex:page>

 

 

Hi, we are trying to use Visualforce Charting in our Sandbox environment and are having difficulties rendering the charts. We can get the data to display but not the chart. The chart itself is blank. Below are our controller and page.  There seems to be a disconnect between the two.  Any ideas on what we may be doing incorrectly?

 

Does Salesforce Support need to enable the functionality in either the production or sandbox environment.

 

 

Controller:

 

 

 

public class vfcTimeToServe {

 

   

 

    // Get a set of Opportunities   

 

    public ApexPages.StandardSetController setCon {

 

        get {

 

            if(setCon == null) {

 

                setCon = new ApexPages.StandardSetController(Database.getQueryLocator(

 

                      [SELECT submitted_to_delivery__c,

 

                    assigned_to_start__c,

 

                                          negotiated_date__c

 

                                          FROM PLC_Job__c

 

                                          WHERE date_time_of_delivery__c= LAST_N_DAYS:90

 

                                          and Team_1__c = 'MCM-Market Research'

 

           

 

                                          limit 5]));

 

                setCon.setPageSize(5);

 

            }

 

            return setCon;

 

        }

 

        set;

 

    }

 

   

 

    public List<PLC_Job__c> getPLCs() {

 

         return (List<PLC_Job__c>) setCon.getRecords();

 

    }

 

}

 

 

 

 

 

 

 

PAGE:

 

 

 

<apex:page controller="vfcTimeToServe">

 

    <apex:chart height="400" width="700" data="{!PLCs}">

 

        <apex:axis type="Numeric" position="left" fields="submitted_to_delivery__c"             title="Days" grid="true"/>

 

        <apex:axis type="Numeric" position="bottom" fields="negotiated_date__c"             title="Month of the Year">

 

        </apex:axis>

 

        <apex:lineSeries axis="left" fill="false" xField="negotiated_date__c" yField="submitted_to_delivery__c"          markerType="cross" markerSize="4" markerFill="#FF0000"/>

 

    </apex:chart>

 

</apex:page>

 

Thanks,

Debbie

 

Hai All, 

Editing the Opportunity Contact Roles related list changes the Last Modified date on the Opportunity, But Opportunity update trigger is not also fired at that time.I want to fire the update trigger in Opportunity while editing contact role in Opportunity.

 

  • August 24, 2009
  • Like
  • 0