DevExpress.chartControt画趋势图

时间:2022-08-09 08:06:47
  private void DrawLine(DataTable dt)
{
Myalysis.Series.Clear();
//图标位置
Myalysis.Legend.AlignmentHorizontal = LegendAlignmentHorizontal.Right;
Myalysis.Legend.AlignmentVertical = LegendAlignmentVertical.Top;
ChartTitle chartTitle = new ChartTitle();
chartTitle.TextColor = System.Drawing.Color.Black;//字体颜色
chartTitle.Font = new Font("Tahoma", );//字体类型字号
chartTitle.Dock = ChartTitleDockStyle.Bottom;//标题对齐方式
chartTitle.Alignment = StringAlignment.Far;
Myalysis.Titles.Clear();//清理标题
Series s_Series = new Series("血糖总览", ViewType.Line);
s_Series.ArgumentScaleType = ScaleType.Qualitative;//x轴类型
s_Series.ValueScaleType = ScaleType.Numerical;//y轴类型
s_Series.PointOptions.PointView = PointView.Values;//显示表示的信息和数据
//X轴的数据字段
s_Series.ArgumentDataMember = "reporttime";
//Y轴的数据字段
s_Series.ValueDataMembers[] = "RESULT";
//定义线条上点的标识形状是否需要
((LineSeriesView)s_Series.View).LineMarkerOptions.Visible = true;
//定义线条上点的标识形状
((LineSeriesView)s_Series.View).LineMarkerOptions.Kind = MarkerKind.Circle;
//定义线条上点的标识颜色
s_Series.View.Color = ColorTranslator.FromHtml("#f90");
//不显示X、Y轴上面的交点的值
((PointSeriesLabel)s_Series.Label).Visible = true;
//线条的类型,虚线,实线
((LineSeriesView)s_Series.View).LineStyle.DashStyle = DashStyle.Solid;
s_Series.DataSource = dt;
Myalysis.Series.Add(s_Series);
foreach (DataRow item in dt.Rows)
{
if (item["diagcode"].ToString() == "".ToString())
{
Series ss_series = new Series("", ViewType.Line);
ss_series.View.Color = Color.Blue;
((LineSeriesView)ss_series.View).LineMarkerOptions.Kind = MarkerKind.Circle;
//X轴的数据字段
s_Series.ArgumentDataMember = "reporttime";
//Y轴的数据字段
s_Series.ValueDataMembers[] = "RESULT"; ss_series.Points.Add(new SeriesPoint(item["reporttime"], item["result"].ToString()));
Myalysis.Series.Add(ss_series);
}
}
//增加水平警戒线
ConstantLine constantLine1 = new ConstantLine();
ConstantLine constantLine2 = new ConstantLine();
constantLine2.AxisValue = 3.9;
constantLine1.AxisValue = ;
constantLine2.LegendText = "正常下限(3.9)";
constantLine1.LegendText = "正常上限(10.0)";
constantLine1.Title.TextColor = Color.Red;
constantLine1.Color = Color.Red;
constantLine2.Color = Color.Green;
constantLine1.LineStyle.DashStyle = DashStyle.Solid;
constantLine2.LineStyle.DashStyle = DashStyle.Solid;
XYDiagram labDiagram = (XYDiagram)Myalysis.Diagram;
         //去掉曲线图中的线条
labDiagram.AxisY.GridLines.Visible = false; labDiagram.AxisY.ConstantLines.Clear();
labDiagram.AxisY.ConstantLines.Add(constantLine1);
labDiagram.AxisY.ConstantLines.Add(constantLine2); }