2009-10-08 11 views

Respuesta

17

Google dice que inserte una tabla como la siguiente:

<img src="http://chart.apis.google.com/chart? 
    chs=250x100 
    &amp;chd=t:60,40 
    &amp;cht=p3 
    &amp;chl=Hello|World" 
    alt="Sample chart" 
/> 

lo que debería ser bastante fácil escribir un HtmlHelper como esto (no probado):

namespace System.Web.Mvc.Html 
{ 
    public static class GoogleChartHelpers 
    { 
     public static string GoogleChart 
      (string cht, string chd, string chs, string chl) 
     { 
      return "<img source='http://chart.apis.google.com/chart?cht=" + cht 
       + "&amp;chd=" + chd 
       + "&amp;chs=" + chs 
       + "&amp;chl=" + chl + "' />; 
     } 
    } 
} 

y lo llaman así:

<%= Html.GoogleChart("P3","t:60,40","250x100","Hello|World") %> 

que debe insertar este en su página:

alt text

Cuestiones relacionadas