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

Simple encode problem in Google Charts through Apex:image Url attribute
Hi
I'm trying to develop a Bar Chart on google chart using simple encoding format ..
I have tried this to my URL attribute in <apex:image>
<apex:pageBlock >
<apex:image title="Transfer Details" alt="Salary for Employees" url="http://chart.apis.google.com/chart?cht=bvg&chd=s:simpleEncode(Array(20000,30000,40000,50000,60000),70000),simpleEncode(Array(3,4,5,6,7),10)&chxt=x,x,y,y,r,r&chxr=4,0,10,2&chxl=0:|{!name}|1:|Transferee+Name|3:|Salary|5:|Job+Level&chf=b0,lg,0,FFE7C6,0,76A4FB,1|bg,s,000000&chs=800x300&chbh=15,5,15" />
</apex:pageBlock>
I have defined the essential Javascript function for simpleEncode as given in google chart parameters
<script type="text/javascript"> var simpleEncoding = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; // This function scales the submitted values so that // maxVal becomes the highest value. function simpleEncode(valueArray,maxValue) { var chartData = ['s:']; for (var i = 0; i < valueArray.length; i++) { var currentValue = valueArray[i]; if (!isNaN(currentValue) && currentValue >= 0) { chartData.push(simpleEncoding.charAt(Math.round((simpleEncoding.length-1) *currentValue / maxValue))); } else { chartData.push('_'); } } return chartData.join(''); } </script>
I have added this function directly into chd:s element
var valueArray = new Array(0,1,4,4,6,11,14,17,23,28,33,36,43,59,65); var maxValue = 70; simpleEncode(valueArray, maxValue);
P.S please ignore the chxl part
I'm new to this and i have no idea about this
Any help would be appreciated
Thanks in Advance
Ajay