谷歌图的HtmlHelper的Asp.net的mvc [英] Google Chart HtmlHelper for Asp.net Mvc

查看:80
本文介绍了谷歌图的HtmlHelper的Asp.net的mvc的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



  是否有谷歌图表API 任何的HtmlHelper扩展? (我喜欢用一些基本的图表,如饼图,条形图)


Are there any HtmlHelper Extensions for Google Chart Api? (I like to use for some basic charts, e.g. Pie Chart, Bar Chart)

梭萌

推荐答案

谷歌表示,插入这样一个图:

Google says that you insert a chart like this:

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

因此​​,它应该很容易写出像这样的的HtmlHelper(未经测试):

So it should be easy enough to write an HtmlHelper like this (untested):

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

和调用它是这样的:

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

这应该插入这个到你的页面:

which should insert this into your page:

这篇关于谷歌图的HtmlHelper的Asp.net的mvc的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆