Question

Y a-t-il des extensions HtmlHelper pour Google Chart Api? (J'aime utiliser pour certains graphiques de base, par exemple Diagramme en camembert, diagramme à barres)

Soe Moe

Était-ce utile?

La solution

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:

text alt

Autres conseils

Une enveloppe C # pour l'API Google Chart.

http://code.google.com/p/googlechartsharp/

Exemples d'utilisation

http://code.google.com/p/googlechartsharp/wiki/UsageExamples

Je suis sûr que vous pouvez créer un HtmlHelper qui intègre cette classe d'emballage pour le rendre encore plus facile.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top