Guest User

Google Chart - Shortcode w/error

a guest
Dec 30th, 2011
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.11 KB | None | 0 0
  1. function chart_shortcode( $atts ) {
  2.     extract(shortcode_atts(array(
  3.         'data' => '',
  4.         'colors' => '',
  5.         'size' => '400x200',
  6.         'bg' => 'ffffff',
  7.         'title' => '',
  8.         'labels' => '',
  9.         'advanced' => '',
  10.         'type' => 'pie'
  11.     ), $atts));
  12.  
  13.     switch ($type) {
  14.         case 'line' :
  15.             $charttype = 'lc'; break;
  16.         case 'xyline' :
  17.             $charttype = 'lxy'; break;
  18.         case 'sparkline' :
  19.             $charttype = 'ls'; break;
  20.         case 'meter' :
  21.             $charttype = 'gom'; break;
  22.         case 'scatter' :
  23.             $charttype = 's'; break;
  24.         case 'venn' :
  25.             $charttype = 'v'; break;
  26.         case 'pie' :
  27.             $charttype = 'p3'; break;
  28.         case 'pie2d' :
  29.             $charttype = 'p'; break;
  30.         default :
  31.             $charttype = $type;
  32.         break;
  33.     }
  34.  
  35.     if ($title) $string .= '&chtt='.$title.'';
  36.     if ($labels) $string .= '&chl='.$labels.'';
  37.     if ($colors) $string .= '&chco='.$colors.'';
  38.     $string .= '&chs='.$size.'';
  39.     $string .= '&chd=t:'.$data.'';
  40.     $string .= '&chf='.$bg.'';
  41.  
  42.     return '<img title="'.$title.'" src="http://chart.apis.google.com/chart?cht='.$charttype.''.$string.$advanced.'" alt="'.$title.'" />';
  43. }
  44. add_shortcode('chart', 'chart_shortcode');
Add Comment
Please, Sign In to add comment