• ASP.NET数据报表之柱状图 ------工作日志


    #region 柱形色调
    /// <summary>
    /// 柱形色调
    /// </summary>
    private string[] myColor = new string[]
    {
    "DarkGreen",
    "DimGray",
    "DodgerBlue",
    "Orchid", //Peru
    "Orange",
    "Orchid",
    "Gold",
    "Peru",
    "Lime",
    "Tan",
    "Red",
    "GreenYellow",
    "DarkGreen",
    "DimGray",
    "Orchid"
    };
    #endregion

    #region 创建webchart实例
    /// <summary>
    /// 创建webchart实例
    /// </summary>
    /// <param name="listValue"></param>
    /// <param name="listText"></param>
    private void bindchart(ArrayList listValue, ArrayList listText)
    {
    //遍历DataTable为每条记录生成一个柱状
    int maxValue = 0;
    int max_ = 0;
    for (int i = 0; i < listValue.Count; i++)
    {
    if (Convert.ToInt32(listValue[i]) > max_)
    {
    max_ = Convert.ToInt32(listValue[i]);
    maxValue = i;
    }
    //创建对象
    ColumnChart mychart = new ColumnChart();

    //设置柱子宽度
    mychart.MaxColumnWidth = 44;
    //颜色
    mychart.Fill.Color = Color.FromName(this.myColor[i]);
    //在柱子上显示数量
    mychart.DataLabels.Visible = true;
    //数量的字体
    mychart.DataLabels.Font = new Font("Verdana", 16);

    //添加
    float dsfgd = float.Parse(listValue[i].ToString());
    mychart.Data.Add(new ChartPoint("", float.Parse(listValue[i].ToString())));
    //备注
    mychart.Legend = listText[i].ToString();

    this.chartSp.Charts.Add(mychart);
    this.chartSp.XTitle.Text = mychart.Legend;
    }
    //辅助设置
    //背景色
    //ChartControl1.Background.Color = Color.FromArgb(55, 0, 16);
    chartSp.YAxisFont.ForeColor = Color.FromArgb(165, 0, 16);//(165, 0, 16);
    chartSp.XAxisFont.ForeColor = Color.FromArgb(165, 0, 16);
    chartSp.YValuesFormat = "{0}"; //{0:N}
    //内部线条
    chartSp.Border.Color = Color.FromArgb(200, 200, 200);
    //边框样式
    chartSp.BorderStyle = BorderStyle.None;
    //y最大值
    double max = double.Parse(listValue[maxValue].ToString());
    int intv = 2;

    //数量小于16的情况
    if (max < 16)
    {
    max = 16;
    }
    //大于16的情况
    else
    {
    intv = int.Parse(Math.Ceiling(max / 8).ToString());
    max += intv;
    }

    //设置Y轴终点值
    chartSp.YCustomEnd = int.Parse(max.ToString());
    //y递增值
    chartSp.YValuesInterval = intv;

    //生成
    this.chartSp.RedrawChart();
    }
    #endregion


    #region 绑定全部数据
    public void ShowAllData()
    {
    if (Session["admin_Number"] == null)
    {
    Response.Write("<script language=javascript>alert('连接超时,请重新登录!!');</script>");
    Response.Write("<script language=javascript>parent.location.href='admin_Login_.aspx'</script>");
    Response.Write("<script language=javascript>window.open('admin_Login_.aspx');opener=null;top.close();</script>");
    }
    else
    {
    BLL_StatisticSP sp = new BLL_StatisticSP();
    ArrayList listValue = new ArrayList();//值
    ArrayList listText = new ArrayList();//显示文本
    int yhl = sp.GetAllYHL();//用户量
    int sbl = sp.GetAllSBL();//设备量
    int zsl = sp.GetAllSpShow();//展示量
    int djl = sp.GetAllDJL();//点击量
    int azl = sp.GetAllAZL();//安装量
    int app = sp.GetAppCount(""); //应用数
    int appUser = sp.GetAppUserCount("");//开发者人数
    listValue.Add(yhl);
    listValue.Add(sbl);
    listValue.Add(zsl);
    listValue.Add(djl);
    listValue.Add(azl);
    listText.Add("用户量");
    listText.Add("设备量");
    listText.Add("展示量");
    listText.Add("点击量");
    listText.Add("apk安装量");
    this.lblYHl.Text = yhl + "人";
    this.lblSBL.Text = sbl + "部";
    this.lblZSL.Text = zsl + "次";
    this.lblDJL.Text = djl + "次";
    this.lblAZL.Text = azl + "次";
    this.lblAPP.Text = app + "个";
    this.lblAppUser.Text = appUser + "人";
    bindchart(listValue, listText);
    }

    }
    #endregion

  • 相关阅读:
    linux使用命令记录
    (转)如何连接远程桌面
    PLSQL将查询结果复制为insert语句
    用foxPro打开dbf文件
    (转)PLSQL新手使用教程
    CPN TOOL使用
    运行mongoDB
    PLSQL连接数据库
    剑指 Offer 10- II. 青蛙跳台阶问题(简单)
    剑指 Offer 10- I. 斐波那契数列(简单)
  • 原文地址:https://www.cnblogs.com/DBtwoer/p/3987768.html
Copyright © 2020-2023  润新知