2009-10-08 12 views

Antwort

17

Google sagt, dass Sie ein Diagramm wie folgt ein:

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

So sollte es leicht sein, genug zu schreiben, eine Htmlhelper so (ungetestet):

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

und nennen sie es wie folgt aus:

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

, die diese in eine Seite einfügen sollte:

alt text