zoukankan      html  css  js  c++  java
  • 图形化报表

    1,常用的图形化报表组件(Highchars(纯js)、水晶报表、jqChart、MsChart、XtraReports)

    2,最常用的属性包括:

    ChartAreas:增加多个绘图区域,每个绘图区域包含独立的图表组、数据源,用于多个图表类型在一个绘图区不兼容时。

    AlignmentOrientation:图表区对齐方向,定义两个绘图区域间的对齐方式。

    AlignmentStyle:图表区对齐类型,定义图表间用以对其的元素。

    AlignWithChartArea:参照对齐的绘图区名称。

    InnerPlotPosition:图表在绘图区内的位置属性。

    Auto:是否自动对齐。

    Height:图表在绘图区内的高度(百分比,取值在0-100)

    Width:图表在绘图区内的宽度(百分比,取值在0-100)

    X,Y:图表在绘图区内左上角坐标

    Position:绘图区位置属性,同InnerPlotPosition。

    Name:绘图区名称。

    Axis:坐标轴集合

    Title:坐标轴标题

    TitleAlignment:坐标轴标题对齐方式

    Interval:轴刻度间隔大小

    IntervalOffset:轴刻度偏移量大小

    MinorGrid:次要辅助线

    MinorTickMark:次要刻度线

    MajorGrid:主要辅助线

    MajorTickMark:主要刻度线

    DataSourceID:MSChart的数据源。

    Legends:图例说明。

    Palette:图表外观定义。

    Series:最重要的属性,图表集合,就是最终看到的饼图、柱状图、线图、点图等构成的集合;可以将多种相互兼容的类型放在一个绘图区域内,形成复合图。

    IsValueShownAsLabel:是否显示数据点标签,如果为true,在图表中显示每一个数据值

    Label:数据点标签文本

    LabelFormat:数据点标签文本格式

    LabelAngle:标签字体角度

    Name:图表名称

    Points:数据点集合

    XValueType:横坐标轴类型

    YValueType:纵坐标轴类型

    XValueMember:横坐标绑定的数据源(如果数据源为Table,则填写横坐标要显示的字段名称)

    YValueMembers:纵坐标绑定的数据源(如果数据源为Table,则填写纵坐标要显示的字段名称,纵坐标可以有两个)

    ChartArea:图表所属的绘图区域名称

    ChartType:图表类型(柱形、饼形、线形、点形等)

    Legend:图表使用的图例名称

    Titles:标题集合。

    width:MSChart的宽度。

    height:MSChart的高度。

    string sql = @"select DATEPART(MONTH,dtmMeasure)as 'Month',
                AVG(Temperature) as 'AvgTemp' 
                        from Wether 
                        where CityName='重庆'
                        group by DATEPART(MONTH,dtmMeasure) 
                        order by Month desc";
    
                DataSet ds = SqlHelper.ExecuteDataSet(sql,null);
                //设置图标背景颜色
                this.Chart1.BackColor = Color.Azure;
                //设置图表框样式
                this.Chart1.BorderlineColor = Color.Green;
                this.Chart1.BorderlineWidth = 5;
                this.Chart1.BorderlineDashStyle = ChartDashStyle.Solid;
                this.Chart1.Titles.Add("重庆市月平均气温走势图");
    
                //设置图表X,Y轴绑定的列
                this.Chart1.Series[0].XValueMember = "Month";
                this.Chart1.Series[0].YValueMembers = "AvgTemp";
                //设置每个数据点标签上显示的值为数据点的值
                this.Chart1.Series[0].IsValueShownAsLabel = true;
                //设置数据点标签的文本格式
                this.Chart1.Series[0].LabelFormat = "{0}°";
                //绑定数据源
                this.Chart1.DataSource = ds;
                this.Chart1.DataBind();
     string sql = @"select (case
                                    when Score<60 then '不及格'
                                    when Score<80 then '及格'
                                    when Score<60 then '不及格'
                                    when Score<90 then '良'
                                    when Score<=100 then '优秀' end)as Grade,
                                    COUNT(*)as 'count'
                                    from prees
                                    group by(case
                                        when Score<60 then '不及格'
                                        when Score<80 then '及格'
                                        when Score<60 then '不及格'
                                        when Score<90 then '良'
                                        when Score<=100 then '优秀' end)";
                DataSet ds = SqlHelper.ExecuteDataSet(sql,null);
                //为图表添加序列
                this.Chart1.Series.Clear();
                this.Chart1.Series.Add("Score");
                //设置序列的图表类型
                this.Chart1.Series["Score"].ChartType = SeriesChartType.Pie;
                //设置图片的背景颜色
                this.Chart1.BackColor = Color.Azure;
                //设置图表边框样式
                this.Chart1.BorderlineColor = Color.Green;
                this.Chart1.BorderlineWidth = 5;
                this.Chart1.BorderlineDashStyle = ChartDashStyle.Solid;
                this.Chart1.Titles.Add("C#成绩统计图");
    
    
                this.Chart1.Series["Score"].LabelForeColor = Color.Gray;
                this.Chart1.Series["Score"].Font = new Font("宋体",14);
                //计算总人数
                int total = 0;
                foreach (DataRow item in ds.Tables[0].Rows)
                {
                    total += Convert.ToInt32(item["Count"]);
                }
                foreach (DataRow item in ds.Tables[0].Rows)
                {
                    //定义数据点
                    DataPoint point = new DataPoint();
                    point.YValues = new double[] { Convert.ToDouble(item["Count"])};
                    //设置没一点数据点标签的文本值为百分比
                    point.Label = string.Format("{0:f2}",Convert.ToDouble(item["Count"])/total*100);
                    //设置图例
                    this.Chart1.Legends.Add(item["Grade"].ToString());
                    point.LegendText = item["Grade"].ToString();
                    //将数据点添加到序列中
                    this.Chart1.Series["Score"].Points.Add(point);
                    //将数据点标签显示到图形外侧
                    Chart1.Series["Score"]["PieLabelStyle"] = "Outside";
                    //将第一个数据点展开
                    Chart1.Series["Score"]["Exploded"] = "true";
                }
  • 相关阅读:
    优步UBER司机全国各地奖励政策汇总 (3月21日-3月27日)
    成都Uber优步司机奖励政策(3月21日)
    北京Uber优步司机奖励政策(3月21日)
    滴滴快车奖励政策,高峰奖励,翻倍奖励,按成交率,指派单数分级(3月21日)
    成都Uber优步司机奖励政策(3月20日)
    北京Uber优步司机奖励政策(3月20日)
    Java多线程-线程的同步与锁
    Java多线程-线程的生命周期
    Java多线程-概念与原理
    Java多线程教程
  • 原文地址:https://www.cnblogs.com/dclcc/p/3485815.html
Copyright © 2011-2022 走看看