日期:2014-05-17  浏览次数:20416 次

求一个asp.net MVC2实现柱状图和折线图的例子
  求一个MVC2实现柱状图和折线图的例子,以前没做过柱状图和折线图,我是用MVC2做的一个项目,后来加了需求,需要统计财务,各个部门的工资状态 ,各个部门每个月发了多少工资,用柱状图显示,然后还要弄一个折线图,显示那个比率,比如说增长了多少...急!求高手指点,可以发我的邮箱(vipchary@163.com),希望能详细一点.
mvc asp.net

------解决方案--------------------
不是有CHART控件嘛?
------解决方案--------------------
现在的人怎么都这么懒。。。都告诉你用chart了,你百度搜MVC CHART例子一把一把的,挑自己适用的。唉。。。
------解决方案--------------------
柱状图表代码:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;

public partial class Result : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        string cmdtxt1 = "server=(local);database=db_13;Uid=sa;Pwd=";
        SqlConnection Con = new SqlConnection(cmdtxt1);
        Con.Open();
        SqlCommand Com = new SqlCommand("select * from tb_06 where ID=" + Request["ID"] + "", Con);
        SqlDataReader dr = Com.ExecuteReader();
        dr.Read();
        string strContent = null;
        if (dr.HasRows)
        {
            strContent = dr["Content"].ToString();
        }
        dr.Close();
        decimal decNumAll = GetNumAll(strContent);//得到所有票数,C#在除法运算中需用decimal类型,否则将会把小数点后的数去掉
        Response.Write(GetResult(strContent, decNumAll));
    }

/// <summary>
/// 显示图象
/// </summary>
/// <param name="strContent">相关主题下的内容</param>
/// <param name="decNumAll">所有的票数</param>
/// <returns></returns>
    public string GetResult(string strContent, decimal decNumAll)
    {
        string[] arrContent = strContent.Split('
------解决方案--------------------
');
        string strBody = "<body style=text-align:center><table width=60% border=1 cellpadding=0 cellspacing=0 text-align:center>\n";
        foreach (string strContentIN in arrContent)
        {
            string strItemName = strContentIN.Split(',')[1].ToString();//得到选项名称