DevExpress ChartControl 图表应用案例
作者:C/S框架网  发布日期:2015-11-21 12:54:48
  DevExpress ChartControl 图表应用案例




贴图图片




贴图图片



贴图图片




C# Code:

/// <summary>
/// 显示图表
/// </summary>
/// <param name="data">数据源</param>
/// <param name="viewType">图表类型</param>
private void ShowChart(DataTable data, ViewType viewType)
{
   chartControl1.Series.Clear();
   chartControl2.Series.Clear();
   
   //在图表中间显示标题
   chartControl1.Legend.AlignmentHorizontal = LegendAlignmentHorizontal.Center;
   chartControl2.Legend.AlignmentHorizontal = LegendAlignmentHorizontal.Center;
   
   //十字线参数设置
   this.chartControl1.CrosshairOptions.ShowArgumentLabels = true;//移动鼠标时动态显示Y轴数据标签
   this.chartControl1.CrosshairOptions.ShowArgumentLine= true;//显示Y轴线
   this.chartControl1.CrosshairOptions.ShowValueLabels = true;//移动鼠标时动态显示X轴数据标签
   this.chartControl1.CrosshairOptions.ShowValueLine = true;//显示X轴线
   
   Series Series1 = new Series("票数情况", viewType);
   Series1.DataSource = data;//数据源
   Series1.ArgumentScaleType = ScaleType.Qualitative;
   Series1.LabelsVisibility = DevExpress.Utils.DefaultBoolean.True;//每个标签显示数据
   Series1.ArgumentDataMember = "DocDate";// 以哪个字段进行显示
   Series1.ValueScaleType = ScaleType.Numerical;//数值类型
   Series1.ValueDataMembers.AddRange(new string[] { "TotalCount" });// 如:柱状图里的柱的取值字段
   Series1.Visible = true;
   
   Series Series2 = new Series("运费情况", viewType);
   Series2.DataSource = data;//数据源
   Series2.ArgumentScaleType = ScaleType.Qualitative;
   Series2.LabelsVisibility = DevExpress.Utils.DefaultBoolean.True;//每个标签显示数据
   Series2.ArgumentDataMember = "DocDate";// 以哪个字段进行显示
   Series2.ValueScaleType = ScaleType.Numerical;//数值类型
   Series2.ValueDataMembers.AddRange(new string[] { "TotalAmount" });// 如:柱状图里的柱的取值字段
   Series2.Visible = true;
   
   chartControl1.Series.Add(Series1);
   chartControl2.Series.Add(Series2);
   
   //隐藏表格X,Y背景线
   if (chartControl1.Diagram != null && chartControl1.Diagram is XYDiagram)
   {
      (chartControl1.Diagram as XYDiagram).AxisX.GridLines.Visible = false;//隐藏X轴线
      (chartControl1.Diagram as XYDiagram).AxisY.GridLines.Visible = false;//隐藏Y轴线
   }
}

//来源:C/S框架网(www.csframework.com) QQ:1980854898








上一篇 下一篇