This may belong to:
[email protected]

--Ed

On Fri, Jun 25, 2010 at 8:44 AM, arya <[email protected]> wrote:

> Hi All,
>
>
> Was reading about axis scaling and then simple encoding and extended
> encoded. I tried those two java script functions(extended and simple
> encoded), but I getting some js error which says
>  'a[Da] is not a function   [Break on this error] f=a[Da]();for(var
> D=a[qa](),s=f>0&&a[M....Wc(Va);if(za||za===0)j.Vc(za);e=0;d= '
>
> I went through the encoding but didn't get much how they work and how
> data will be properly proportioned to each other.What i learnt is this
> functions converts integer data numeric and alphanumeric string.
> Please can some one take some time to explain me what's happening in
> encoding.
>
> code is
>
> <html>
>  <head>
>  <script type='text/javascript' src='http://www.google.com/jsapi'></
> script>
>  <script type='text/javascript'>
>  google.load('visualization', '1', {packages:['imagelinechart']});
>      google.setOnLoadCallback(drawChart);
> 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('');
> }
> // Same as simple encoding, but for extended encoding.
> var
>
> EXTENDED_MAP='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-.';
> var EXTENDED_MAP_LENGTH = EXTENDED_MAP.length;
>
> function extendedEncode(arrVals, maxVal) {
>  var chartData = 'e:';
>
>  for(i = 0, len = arrVals.length; i <len; i++) {
>    // In case the array vals were translated to strings.
>    var numericVal = new Number(arrVals[i]);
>    // Scale the value to maxVal.
>    var scaledVal = Math.floor(EXTENDED_MAP_LENGTH *
>        EXTENDED_MAP_LENGTH * numericVal / maxVal);
>
>    if(scaledVal > (EXTENDED_MAP_LENGTH * EXTENDED_MAP_LENGTH) - 1) {
>      chartData += "..";
>    } else if (scaledVal < 0) {
>      chartData += '__';
>    } else {
>      // Calculate first and second digits and add them to the output.
>      var quotient = Math.floor(scaledVal / EXTENDED_MAP_LENGTH);
>      var remainder = scaledVal - EXTENDED_MAP_LENGTH * quotient;
>      chartData += EXTENDED_MAP.charAt(quotient) +
> EXTENDED_MAP.charAt(remainder);
>    }
>  }
>
>  return chartData;
> }
>      function drawChart() {
>
>        var valueArray = new
> Array(0,1,4,4,6,11,14,17,23,28,33,36,43,59,65);
>                var maxValue = 70;
>                var data = simpleEncode(valueArray, maxValue);
>                //data = 's:A,B,D,D,F,K,M,P,U,Y,d,f,l,z,5';
>
>
>        var options = new Object();
>                options.width = 500;
>                options.height = 250;
>                options.legend = 'none';
>                options.colors = ['#ff7f00', '#339999', '#cc9966'];
>                options.lineWidth=3;
>                options.pointSize = 5;
>                options.legend = 'bottom'
>
>                alert('data : '+data);
>
>        var chart = new
> google.visualization.ImageLineChart(document.getElementById('chart_div'));
>        //chart.draw(data, {width: 400, height: 240, min: 0});
>        chart.draw(data, options);
>      }
> </script>
> </head>
> <body>
>    <div id='chart_div'></div>
>  </body>
> </html>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Google Chart API" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<google-chart-api%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/google-chart-api?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Chart API" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-chart-api?hl=en.

Reply via email to