2009-10-08 3 views

Répondre

17

Google dit que vous insérez un graphique comme celui-ci:

<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" 
/> 

Il devrait être assez facile d'écrire un HtmlHelper comme celui-ci (non testé):

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 + "' />; 
     } 
    } 
} 

et l'appeler comme ceci:

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

qui devrait l'insérer dans votre page:

alt text

Questions connexes