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
Samuel JohnsonCBESamuel JohnsonCBE 

Visualforce Page

Im trying to put a gauge onto the account page.  Im using the field "variance_by_percentage__c" which I put into the ['label', 'value'].  is this the right place to put it.  I am getting the error: Unknown property 'Account.Variance-by_Percentage__c' referenced in Variance_Gauge which is the name of the page im trying to create.  I want to show the gauge for the account im in.  os that is why i am also using ?id on line #2.  Any sugguestions

<apex:page>
?id=

<apex:sectionHeader title="FRS GROUP DASHBOARD"/>
<font size="20" color="darkblue" > <center> <b> FRS </b> </center> </font>
<html>
<head>
<script type='text/javascript' src='https://www.google.com/jsapi'></script>
<script type='text/javascript'>
google.load('visualization', '1', {packages:['gauge']});
google.setOnLoadCallback(drawChart);
function drawChart() {
var data = new google.visualization.arrayToDataTable([
['Label', 'Value'],
['Variance', value = "{!Account.Variance_by_Percentage__c}"],

]);




var options = {
width: 400, height: 120,
greenFrom: -5, greenTo: 5,
majorTicks: [-20, -15, -10, -5, 0, 5, 10, 15, 20]
Min: -20,
Max: 20,
};





var chart = new google.visualization.Gauge(document.getElementById('chart_div'));
chart.draw(data, options);

</script>
</head>
<body>
<div id='chart_div' ></div>

<div id='visualization' style="width: 1500px; height: 700px "></div>
</body>
</html>

</apex:page>
bob_buzzardbob_buzzard
Your page doesn't use a controller, so there is no Account property to be used to generate the chart.  It sounds like you want to use an Account standard controller, which will make the record that you identify through the 'id' URL parameter available to the page markup and JavaScript.
Samuel JohnsonCBESamuel JohnsonCBE
I got the code to work to get the chart onto my page layout.  Now I can't figure out where or what to put to get the field "Variance by Percent" into the code.  Here is my code that at least shows the gauge. Here is my code.  Any help would be very greatful


<apex:page standardcontroller="Account" sidebar="false" showHeader="false">
<html>
<head>
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript">
google.load("visualization", "1", {packages:["gauge"]});
google.setOnLoadCallback(drawChart);
function drawChart()

{ var data = google.visualization.arrayToDataTable([
['Label', 'Value'], ['Variance', 0],
]);

var options = {
width: 600, height: 320, greenFrom: -5,
greenTo: 5,
min: -50,
max: 50,
majorTicks: [-20, -15, -10, -5, 0, 5, 10, 15, 20] };

var chart = new google.visualization.Gauge(document.getElementById('chart_div'));

chart.draw(data, options);
setInterval(function() {
    data.setValue(0, 1, 40 + Math.round(60 * Math.random()));
    chart.draw(data, options);
  }, 13000); }
</script>
</head>
<body>
     <div id="chart_div" style="width: 400px; height: 120px;"></div>
</body>
</html>
</apex:page>