Exemple #1
0
    private string DrawChart(DataTable dtTemp)
    {
        int zz = dtTemp.Rows.Count - 1;

        if (zz > 0)
        {
            string[] AllWeek          = new string[zz];
            string[] AllAttendanceNum = new string[zz];
            for (int i = 0; i < dtTemp.Rows.Count - 1; i++)
            {
                zz--;
                AllWeek[i]          = dtTemp.Rows[zz]["周次"].ToString();
                AllAttendanceNum[i] = dtTemp.Rows[zz]["合计"].ToString();
            }

            string strXdata = string.Empty;
            foreach (string strData in AllWeek)
            {
                strXdata += strData + "\t";
            }

            string strYdata = string.Empty;
            foreach (string strValue in AllAttendanceNum)
            {
                strYdata += strValue + "\t";
            }

            ChartSpace laySpace    = new ChartSpaceClass();
            ChChart    InsertChart = laySpace.Charts.Add(0);

            InsertChart.Type      = ChartChartTypeEnum.chChartTypeLineStacked;
            InsertChart.HasLegend = false;

            InsertChart.HasTitle              = true;
            InsertChart.Title.Caption         = dtTemp.Rows[0]["系部"] + "学生" + AllWeek[0] + "-" + AllWeek[AllWeek.Length - 1] + "周缺勤情况走势图";
            InsertChart.Axes[0].HasTitle      = true;
            InsertChart.Axes[0].Title.Caption = "周次";
            InsertChart.Axes[1].HasTitle      = true;
            InsertChart.Axes[1].Title.Caption = "缺勤人数";

            InsertChart.SeriesCollection.Add(0);

            InsertChart.SeriesCollection[0].SetData(ChartDimensionsEnum.chDimSeriesNames, (int)ChartSpecialDataSourcesEnum.chDataLiteral, "图例1");
            InsertChart.SeriesCollection[0].SetData(ChartDimensionsEnum.chDimCategories, (int)ChartSpecialDataSourcesEnum.chDataLiteral, strXdata);
            InsertChart.SeriesCollection[0].SetData(ChartDimensionsEnum.chDimValues, (int)ChartSpecialDataSourcesEnum.chDataLiteral, strYdata);

            string strAbsolutePath = (Server.MapPath(".")) + "\\ShowData.gif";
            laySpace.ExportPicture(strAbsolutePath, "GIF", 1450, 250);

            string strRelativePath = "./ShowData.gif";
            Random rd          = new Random();
            string strImageTag = "<IMG SRC='" + strRelativePath + "?id=" + rd.Next(65500) + "'/>";

            return(strImageTag);
        }
        else
        {
            return("");
        }
    }
Exemple #2
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        string        strSeriesName = "图例1";
        string        ConnectString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
        string        Sql           = "SELECT Name,sum(AddMoney) AS Total FROM F_Money  where AddUserId='" + Session["UserId"].ToString() + "' and AddTime>='" + df.Text + "' and AddTime<='" + dt.Text + "'  GROUP BY Name";
        SqlConnection myConn        = new SqlConnection(ConnectString);

        myConn.Open();
        SqlDataAdapter Da = new SqlDataAdapter(Sql, myConn);
        DataSet        ds = new DataSet();

        Da.Fill(ds);
        string[] ProjectType  = new string[14];
        string[] ProjectTotal = new string[14];
        for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
        {
            ProjectType[i]  = ds.Tables[0].Rows[i][0].ToString();
            ProjectTotal[i] = ds.Tables[0].Rows[i][1].ToString();
        }
        string strXdata = String.Empty;

        foreach (string strData in ProjectType)
        {
            strXdata += strData + "\t";
        }
        string strYdata = String.Empty;

        foreach (string strValue in ProjectTotal)
        {
            strYdata += strValue + "\t";
        }
        ChartSpace laySpace    = new ChartSpaceClass();
        ChChart    InsertChart = laySpace.Charts.Add(0);

        InsertChart.Type                  = ChartChartTypeEnum.chChartTypeColumnClustered;
        InsertChart.HasLegend             = false;
        InsertChart.HasTitle              = true;
        InsertChart.Title.Caption         = "收支信息统计图";
        InsertChart.Axes[0].HasTitle      = true;
        InsertChart.Axes[0].Title.Caption = "";
        InsertChart.Axes[1].HasTitle      = true;

        InsertChart.Axes[1].Scaling.SplitMinimum = 0;
        InsertChart.Axes[1].Title.Caption        = "收支金额";
        InsertChart.SeriesCollection.Add(0);
        InsertChart.SeriesCollection[0].SetData(ChartDimensionsEnum.chDimSeriesNames,
                                                +(int)ChartSpecialDataSourcesEnum.chDataLiteral, strSeriesName);
        InsertChart.SeriesCollection[0].SetData(ChartDimensionsEnum.chDimCategories,
                                                +(int)ChartSpecialDataSourcesEnum.chDataLiteral, strXdata);
        InsertChart.SeriesCollection[0].SetData(ChartDimensionsEnum.chDimValues,
                                                (int)ChartSpecialDataSourcesEnum.chDataLiteral, strYdata);
        string strAbsolutePath = (Server.MapPath(".")) + "\\ShowData.gif";

        laySpace.ExportPicture(strAbsolutePath, "GIF", 600, 400);
        string strRelativePath = (Server.MapPath(".")) + "\\ShowData.gif";
        string strImageTag     = "<IMG SRC='" + strRelativePath + "?kkd=" + Guid.NewGuid().ToString() + "&dd=" + DateTime.Now.ToString() + "'/>";

        //this.PlaceHolder1.Controls.Add(new LiteralControl(strImageTag));
    }
Exemple #3
0
        private void button1_Click(object sender, EventArgs e)
        {
            string str = "1999-01-01";
            string str2 = str;
            string str3 = "";
            OleDbBase.DB db = new OleDbBase.DB();
            OleDbDataReader reader = db.Read("select PutDateTime,TW from TW where PutDateTime>= #" + this.dtp1.Value.ToShortDateString() + " 00:00:00# and PutDateTime<= #" + this.dtp2.Value.ToShortDateString() + " 23:59:59# and UserName='******' order by PutDateTime");
            while (reader.Read())
            {
                str2 = DateTime.Parse(reader[0].ToString()).ToString("yyyy-MM-dd");
                if (str != str2)
                {
                    str3 = str3 + ",";
                    str = str2;
                }
                str3 = str3 + reader[1].ToString() + "\t";
            }
            reader.Close();
            ChartSpace space = new ChartSpaceClass();

            ChChart chart = space.Charts.Add(0);
            string str6 = "6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24";
            str6 = str6.Replace(" ", "时\t");
            string[] strArray = str3.Split(',');

            switch (cboStyle.Text)
            {
                case "chChartTypeSmoothLine":
                    chart.Type = ChartChartTypeEnum.chChartTypeSmoothLine;
                    break;
                case "chChartTypeColumnClustered3D":
                    chart.Type = ChartChartTypeEnum.chChartTypeColumnClustered3D;
                    break;

                default:
                    chart.Type = ChartChartTypeEnum.chChartTypeLine;
                    break;
            }
            //chart.Type = ChartChartTypeEnum.chChartTypeSmoothLine;
            chart.HasTitle = true;
            chart.Title.Caption = "体温变化曲线";

            //给定x,y轴图示说明
            chart.Axes[0].HasTitle = true;
            chart.Axes[0].Title.Caption = "测试时间";

            chart.Axes[1].HasTitle = true;
            chart.Axes[1].Title.Caption = "体温";

            chart.SetData(ChartDimensionsEnum.chDimCategories, (int)ChartSpecialDataSourcesEnum.chDataLiteral, str6);
            for (int i = 1; i < strArray.Length; i++)
            {
                chart.SeriesCollection.Add(i).SetData(ChartDimensionsEnum.chDimValues, (int)ChartSpecialDataSourcesEnum.chDataLiteral, strArray[i]);
            }
            space.ExportPicture("OK.gif", "gif", 760, 500);
            this.pictureBox1.ImageLocation = "OK.gif";
        }
Exemple #4
0
        private void button1_Click(object sender, EventArgs e)
        {
            string str  = "1999-01-01";
            string str2 = str;
            string str3 = "";

            OleDbBase.DB    db     = new OleDbBase.DB();
            OleDbDataReader reader = db.Read("select PutDateTime,TW from TW where PutDateTime>= #" + this.dtp1.Value.ToShortDateString() + " 00:00:00# and PutDateTime<= #" + this.dtp2.Value.ToShortDateString() + " 23:59:59# and UserName='******' order by PutDateTime");

            while (reader.Read())
            {
                str2 = DateTime.Parse(reader[0].ToString()).ToString("yyyy-MM-dd");
                if (str != str2)
                {
                    str3 = str3 + ",";
                    str  = str2;
                }
                str3 = str3 + reader[1].ToString() + "\t";
            }
            reader.Close();
            ChartSpace space = new ChartSpaceClass();

            ChChart chart = space.Charts.Add(0);
            string  str6  = "6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24";

            str6 = str6.Replace(" ", "时\t");
            string[] strArray = str3.Split(',');

            switch (cboStyle.Text)
            {
            case "chChartTypeSmoothLine":
                chart.Type = ChartChartTypeEnum.chChartTypeSmoothLine;
                break;

            case "chChartTypeColumnClustered3D":
                chart.Type = ChartChartTypeEnum.chChartTypeColumnClustered3D;
                break;

            default:
                chart.Type = ChartChartTypeEnum.chChartTypeLine;
                break;
            }
            //chart.Type = ChartChartTypeEnum.chChartTypeSmoothLine;
            chart.HasTitle      = true;
            chart.Title.Caption = "体温变化曲线";

            //给定x,y轴图示说明
            chart.Axes[0].HasTitle      = true;
            chart.Axes[0].Title.Caption = "测试时间";

            chart.Axes[1].HasTitle      = true;
            chart.Axes[1].Title.Caption = "体温";

            chart.SetData(ChartDimensionsEnum.chDimCategories, (int)ChartSpecialDataSourcesEnum.chDataLiteral, str6);
            for (int i = 1; i < strArray.Length; i++)
            {
                chart.SeriesCollection.Add(i).SetData(ChartDimensionsEnum.chDimValues, (int)ChartSpecialDataSourcesEnum.chDataLiteral, strArray[i]);
            }
            space.ExportPicture("OK.gif", "gif", 760, 500);
            this.pictureBox1.ImageLocation = "OK.gif";
        }