ComponentArt.Charting.WebChart 控件Demo

 

OleDbConnection ocon = new OleDbConnection(System.Configuration.ConfigurationSettings.AppSettings[0].ToString());//("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D://pic.MDB;");
        
       /* SqlConnection scon = new SqlConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D://pic.MDB;");//(System.Configuration.ConfigurationSettings.AppSettings[0]);
        
        SqlCommand scmd = new SqlCommand("select * from DataTab",scon);
        SqlDataAdapter da = new SqlDataAdapter(scmd);

        DataSet ds = new DataSet();
        da.Fill(ds);
       */
        OleDbCommand ocmd = new OleDbCommand("select * from DataTab",ocon);
        OleDbDataAdapter da = new OleDbDataAdapter(ocmd);
        DataSet ds = new DataSet();
        da.Fill(ds);

        WebChart1.Series.Add(new ComponentArt.Charting.Series("系列4"));
        Response.Write(ds.Tables[0].Columns[0].Caption.ToString());
        //定义x,y轴
        double[] y = new double[] { 50, 60, 70, 80, 90, 100 };
        string[] x = new string[] { "50", "100", "150", "200", "", "" };
        WebChart1.DefineValue("x", x);
        WebChart1.DefineValue("y", y);
        WebChart1.DataBind();
        
        //设置折线点的数据
        int n = ds.Tables[0].Columns.Count;
        int p = ds.Tables[0].Rows.Count;
        int[] sales = new int[n];
        for (int index1 = 1; index1 < n;index1++ )
        {
            sales[index1] = int.Parse(ds.Tables[0].Rows[0][index1].ToString());
        }
        Color[] colour = new Color[8] { Color.Red, Color.White, Color.Red, Color.White, Color.Red, Color.White, Color.Red, Color.White };
        
        WebChart1.DefineValue(ds.Tables[0].Rows[0][0].ToString() + ":y", sales);
        WebChart1.DefineValue(ds.Tables[0].Rows[0][0].ToString() + ":color", colour);
        int[] sales1 = new int[n];
        for (int index2 = 1; index2 < n; index2++)
        {
            sales1[index2] = int.Parse(ds.Tables[0].Rows[2][index2].ToString());
        }
        Color[] colour1 = new Color[8] { Color.Red, Color.White, Color.Red, Color.White, Color.Red, Color.White, Color.Red, Color.White };
        WebChart1.DefineValue(ds.Tables[0].Rows[2][0].ToString() + ":y", sales1);
        WebChart1.DefineValue(ds.Tables[0].Rows[2][0].ToString() + ":color", colour1);
        
        int[] sales2 = new int[n];
        for (int index2 = 1; index2 < n; index2++)
        {
            sales2[index2] = int.Parse(ds.Tables[0].Rows[1][index2].ToString());
        }
        Color[] colour2 = new Color[8] { Color.Red, Color.White, Color.Red, Color.White, Color.Red, Color.White, Color.Red, Color.White };
        WebChart1.DefineValue(ds.Tables[0].Rows[1][0].ToString() + ":y", sales2);
        WebChart1.DefineValue(ds.Tables[0].Rows[1][0].ToString() + ":color", colour2);
        double[] sales3 = new double[8] { 68.35, 70.84, 67.79, 56.36, 56.88, 81.87, 88.2, 108 };
        Color[] colour3 = new Color[8] { Color.Red, Color.White, Color.Red, Color.White, Color.Red, Color.White, Color.Red, Color.White };
        WebChart1.DefineValue("系列4:y", sales3);
        WebChart1.DefineValue("系列4:color", colour3);
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值