Difference between revisions of "Google Charts"

From Second Life Wiki
Jump to navigation Jump to search
(New page: <lsl> string simpleEncoding = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; string simpleEncode(list values) { string text = ""; float max = llListStatistics(...)
(No difference)

Revision as of 18:33, 31 December 2007

<lsl> string simpleEncoding = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; string simpleEncode(list values) {

   string text = "";
   float max = llListStatistics(LIST_STAT_MAX, values);
   
   integer count = llGetListLength(values);
   
   integer index;
   
   for(index = 0; index < count; index++)
   {
       integer value = llList2Integer(values, index);
       if(value < 0)
           text += "_";
       else
       {
           float percent = value / max;
           value = llFloor(percent * 61);
           text += llGetSubString(simpleEncoding, value, value);
       }
   }
   return text;

} string chartUrl(list values, list captions) {

   integer i;
   integer n = llGetListLength(captions);
   string url = "http://chart.apis.google.com/chart";
   url += "?chs=200x125";
   url += "&chd=s:" + simpleEncode(values);
   url += "&cht=lc";
   url += "&chxt=x,y";
   url += "&chxl=0:";
   for(i = 0; i < n; i++)
       url += "|" + llEscapeURL(llList2String(captions, i));
   url += "|1:||" + (string)llCeil(llListStatistics(LIST_STAT_MAX, values));
   return url;

} </lsl>