• DevExpress.chartControt画趋势图


     1  private void DrawLine(DataTable dt)
     2         {
     3             Myalysis.Series.Clear();
     4             //图标位置
     5             Myalysis.Legend.AlignmentHorizontal = LegendAlignmentHorizontal.Right;
     6             Myalysis.Legend.AlignmentVertical = LegendAlignmentVertical.Top;
     7             ChartTitle chartTitle = new ChartTitle();    
     8             chartTitle.TextColor = System.Drawing.Color.Black;//字体颜色
     9             chartTitle.Font = new Font("Tahoma", 12);//字体类型字号
    10             chartTitle.Dock = ChartTitleDockStyle.Bottom;//标题对齐方式
    11             chartTitle.Alignment = StringAlignment.Far;
    12             Myalysis.Titles.Clear();//清理标题         
    13             Series s_Series = new Series("血糖总览", ViewType.Line);
    14             s_Series.ArgumentScaleType = ScaleType.Qualitative;//x轴类型
    15             s_Series.ValueScaleType = ScaleType.Numerical;//y轴类型
    16             s_Series.PointOptions.PointView = PointView.Values;//显示表示的信息和数据
    17             //X轴的数据字段
    18             s_Series.ArgumentDataMember = "reporttime";           
    19             //Y轴的数据字段
    20             s_Series.ValueDataMembers[0] = "RESULT";
    21             //定义线条上点的标识形状是否需要
    22             ((LineSeriesView)s_Series.View).LineMarkerOptions.Visible = true;          
    23             //定义线条上点的标识形状
    24             ((LineSeriesView)s_Series.View).LineMarkerOptions.Kind = MarkerKind.Circle;
    25             //定义线条上点的标识颜色
    26             s_Series.View.Color = ColorTranslator.FromHtml("#f90");
    27             //不显示X、Y轴上面的交点的值
    28             ((PointSeriesLabel)s_Series.Label).Visible = true;
    29             //线条的类型,虚线,实线
    30             ((LineSeriesView)s_Series.View).LineStyle.DashStyle = DashStyle.Solid;
    31             s_Series.DataSource = dt;
    32             Myalysis.Series.Add(s_Series);
    33             foreach (DataRow item in dt.Rows)
    34             {
    35                 if (item["diagcode"].ToString() == "1111".ToString())
    36                 {
    37                     Series ss_series = new Series("", ViewType.Line);
    38                     ss_series.View.Color = Color.Blue;
    39                     ((LineSeriesView)ss_series.View).LineMarkerOptions.Kind = MarkerKind.Circle;
    40                     //X轴的数据字段
    41                     s_Series.ArgumentDataMember = "reporttime";
    42                     //Y轴的数据字段
    43                     s_Series.ValueDataMembers[0] = "RESULT";
    44 
    45                     ss_series.Points.Add(new SeriesPoint(item["reporttime"], item["result"].ToString()));
    46                     Myalysis.Series.Add(ss_series);
    47                 }
    48             }
    49             //增加水平警戒线
    50             ConstantLine constantLine1 = new ConstantLine();
    51             ConstantLine constantLine2 = new ConstantLine();
    52             constantLine2.AxisValue = 3.9;
    53             constantLine1.AxisValue = 10;
    54             constantLine2.LegendText = "正常下限(3.9)";
    55             constantLine1.LegendText = "正常上限(10.0)";
    56             constantLine1.Title.TextColor = Color.Red;
    57             constantLine1.Color = Color.Red;
    58             constantLine2.Color = Color.Green;
    59             constantLine1.LineStyle.DashStyle = DashStyle.Solid;
    60             constantLine2.LineStyle.DashStyle = DashStyle.Solid;
    61             XYDiagram labDiagram = (XYDiagram)Myalysis.Diagram;
             //去掉曲线图中的线条
    62 labDiagram.AxisY.GridLines.Visible = false;64 labDiagram.AxisY.ConstantLines.Clear(); 65 labDiagram.AxisY.ConstantLines.Add(constantLine1); 66 labDiagram.AxisY.ConstantLines.Add(constantLine2); 67 68 }
  • 相关阅读:
    CArray类模板封装示例
    环形队列CQueue类模板示例
    CStack栈模板封装示例
    TSIC506驱动程序
    proteus虚拟串口实现
    js学习笔记(一)
    提升网页性能
    JS性能优化笔记搜索整理
    @font-face制作Web Icon
    原生js动画效果(源码解析)
  • 原文地址:https://www.cnblogs.com/WangJunZzz/p/5684119.html
Copyright © 2020-2023  润新知