You need to sign in to do that
Don't have an account?
Veli Nadir
Google Charts Timeline in VF page
I want to use Timeline from Google Charts to display the start and end dates of projects for custom object Project__c. I I tried the following controller and VF page but it doesn't work. Can someone help me regarding this issue?
Controller:
VF page:
Controller:
global with sharing class GoogleChartsController { @RemoteAction global static Project__c[] loadPros() { return [select Id, Name, Project_Start__c, End_Date__c from Project__c]; } }
VF page:
<apex:page controller="GoogleChartsController" sidebar="false"> <!-- Google API inclusion --> <apex:includeScript id="a" value="https://www.google.com/jsapi" /> <!-- Google Timeline will be drawn in this DIV --> <div id="chartBlock" /> <script type="text/javascript"> // Load the Visualization API and the timeline package. google.load('visualization', '1.0', {'packages':['timeline']}); // Set a callback to run when the Google Visualization API is loaded. google.setOnLoadCallback(initCharts); function initCharts() { // Following the usual Remoting syntax // [<namespace>.]<controller>.<method>([params...,] <callbackFunction>(result, event) {...} // controller : GoogleChartsController // method : loadPros GoogleChartsController.loadPros( function(result, event){ // load Timeline var visualization = new google.visualization.Timeline(document.getElementById('chartBlock')); // Prepare table model for chart with columns var data = new google.visualization.DataTable(); data.addColumn('string', 'Project'); data.addColumn('date', 'Start'); data.addColumn('date', 'End'); // add rows from the remoting results for(var i =0; i<result.length;i++){ var r = result[i]; data.addRow([r.Name, r.Project_Start__c, r.End_Date__c]); } // draw the timeline. visualization.draw(data); }, {escape:true}); } </script> </apex:page>
Controller:
VF Page: