⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 chart.ascx.cs

📁 一个土地管理系统
💻 CS
字号:
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 ComponentArt.Charting.Design;
using ComponentArt.Charting;

public partial class UserControl_Chart : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        { 
            printChart();
        }
    }
    void printChart()
    {
        // Define two arrays 
        

        DataTable table = DataOp.getData("select [id],[landPurpose] from [landPurpose]");
        DataTable table2 = new DataTable();
        DataColumn dc = new DataColumn("purpose",typeof(string));
        table2.Columns.Add(dc);
        dc = new DataColumn("purposeCount", typeof(int));
        table2.Columns.Add(dc);
        dc = new DataColumn("purposePercent", typeof(double));
        table2.Columns.Add(dc);

        foreach (DataRow r in table.Rows)
        {

            DataTable t = DataOp.getData("select count(*) from [landInfo] where [landPurpose]= " + Convert.ToInt32(r.ItemArray[0]));
            DataRow dr = table2.NewRow();
            if (Convert.ToInt32(t.Rows[0].ItemArray[0]) <= 0)
                continue;

            if (t.Rows.Count > 0)
            {
              
                dr["purpose"] = r.ItemArray[1].ToString();
                dr["purposeCount"] = Convert.ToInt32(t.Rows[0].ItemArray[0]);

                if (table.Rows.Count > 0)
                {
                    double scale = Convert.ToDouble(t.Rows[0].ItemArray[0]) / Convert.ToDouble(LandData.getLandNum());
                
                    string percent = string.Format("{0:0.0000}",scale);
                    scale = Convert.ToDouble(percent);
                    dr["purposePercent"] = scale;
                }
            }
            table2.Rows.Add(dr);
        }

 

        double[] y = new double[] { 25.1, 35.1, 60.1, 98.1, 76.1, 70.9 };
        string[] x = new string[] { "Jan", "Feb", "Mar", "Apr", "May", "Jun" };

        // Set viewpoint
       // targetChart.View.ViewDirection = new Vector3D(1, 10, 10);

        //targetChart.DefineValue("x", x);
        //targetChart.DefineValue("y", y);
        // Set viewpoint
       // targetChart.View.ViewDirection = new Vector3D(1, 10, 10);

        targetChart.DefineValue("x", table2.Columns["purpose"]);
        targetChart.DefineValue("y", table2.Columns["purposePercent"]);
        targetChart.MainStyle = "Pie";

        // Create the series
        Series s = new Series("S0");
        targetChart.Series.Add(s);

        // Create datapoint labels
        SeriesLabels labels = new SeriesLabels();
        s.Labels.Add(labels);
        // By default, labels show the "y" parameter.
        // Customize labels
        labels.LabelExpression = "x + '=' + y*100+'%'";

        targetChart.DataBind();
        targetChart.View.Kind = ProjectionKind.TwoDimensional;
        targetChart.BackColor = System.Drawing.Color.FromArgb(239,231,222);
        // Customize labels style
        //DataPointLabelStyle LS = targetChart.DataPointLabelStyles[0];
       // LS.ForeColor = System.Drawing.Color.LightYellow;
       // LS.ShadowDepthPxl = 1;
       // LS.Font = new System.Drawing.Font("宋体,Times New Roman",30);

  

    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -