You need to sign in to do that
Don't have an account?

Google Chart in VF
<apex:page >
<apex:includeScript id="a" value="https://www.google.com/jsapi" />
<apex:sectionHeader subtitle="Reactive Call Outs Per Day"/>
<!-- Google Charts will be drawn in this DIV -->
<div id="chart_div" />
<script type="text/javascript" src="/soap/ajax/29.0/apex.js"></script>
<script type="text/javascript" src="/soap/ajax/20.0/connection.js"></script>
<script type="text/javascript">
var result = sforce.connection.query("SELECT DAY_ONLY(CreatedDate) days, count(createdDate) counts FROM Visits__c where createdDate = LAST_N_Days:90 GROUP BY DAY_ONLY(CreatedDate) order by DAY_ONLY(createdDate) desc");
records = result.getArray("records");
alert(records);
// Load the Visualization API and the piechart package.
google.load('visualization', '1.0', {'packages':['corechart']});
google.setOnLoadCallback(drawCharts);
function drawCharts() {
var data = new google.visualization.arrayToDataTable();
data.addColumn('date', 'Created Date');
data.addColumn('number', 'Record Count');
for(var i =0; i<records.length;i++)
data.Rows.add(['records[i].days', 'records[i].counts']);
var options = {
title: '',
hAxis: {title: 'days'},
vAxis: {title: 'counts'},
legend: 'none',
trendlines: { 0: {color: 'red',} } // Draw a trendline for data series 0.
};
var visualization = new google.visualization.ColumnChart(document.getElementById('chart_div'));
visualization.draw(data,options);
}
</script>
</apex:page>
In this above code Query working correctly. But Chart is not displayed Why?.......
<apex:includeScript id="a" value="https://www.google.com/jsapi" />
<apex:sectionHeader subtitle="Reactive Call Outs Per Day"/>
<!-- Google Charts will be drawn in this DIV -->
<div id="chart_div" />
<script type="text/javascript" src="/soap/ajax/29.0/apex.js"></script>
<script type="text/javascript" src="/soap/ajax/20.0/connection.js"></script>
<script type="text/javascript">
var result = sforce.connection.query("SELECT DAY_ONLY(CreatedDate) days, count(createdDate) counts FROM Visits__c where createdDate = LAST_N_Days:90 GROUP BY DAY_ONLY(CreatedDate) order by DAY_ONLY(createdDate) desc");
records = result.getArray("records");
alert(records);
// Load the Visualization API and the piechart package.
google.load('visualization', '1.0', {'packages':['corechart']});
google.setOnLoadCallback(drawCharts);
function drawCharts() {
var data = new google.visualization.arrayToDataTable();
data.addColumn('date', 'Created Date');
data.addColumn('number', 'Record Count');
for(var i =0; i<records.length;i++)
data.Rows.add(['records[i].days', 'records[i].counts']);
var options = {
title: '',
hAxis: {title: 'days'},
vAxis: {title: 'counts'},
legend: 'none',
trendlines: { 0: {color: 'red',} } // Draw a trendline for data series 0.
};
var visualization = new google.visualization.ColumnChart(document.getElementById('chart_div'));
visualization.draw(data,options);
}
</script>
</apex:page>
In this above code Query working correctly. But Chart is not displayed Why?.......
You can always debug the javaa script code by the below steps
Hope this resolves your problem.
Thanks,
Karanraj (http://www.karanrajs.com)
All Answers
You can always debug the javaa script code by the below steps
Hope this resolves your problem.
Thanks,
Karanraj (http://www.karanrajs.com)