在线客服 联系我们 返回顶部
企业动态 技术分享 行业动态

DevExpress之ChartControl的SeriesTemplate实例

2019-08-09

本文实例讲述了devexpress之chartcontrol的seriestemplate用法,分享给大家供大家参考。具体方法如下:

关键代码如下:





namespace devexpresschart
{
  public partial class wingsp : form
  {
  public wingsp
  {
  initializecomponent;
  }
  static readonly string accessfullpath = string.format;
  static datatable gsplist = null;
  accessutilsv2 accesshelper = null;
  private void wingsp_load
  {













  accesshelper = new accessutilsv2;
  gsplist = accesshelper.executedatatable;
  builderdevchart;
  }
  private void builderdevchart
  {
  if
  {
  chartcontrol1.seriesdatamember = "year";
  chartcontrol1.seriestemplate.argumentdatamember = "region";
  chartcontrol1.seriestemplate.valuedatamembers.addrange;
  chartcontrol1.seriesnametemplate.begintext = "gsp in ";
  chartcontrol1.datasource = gsplist;













  chartcontrol1.setxlableangle;
  chartcontrol1.setcrosshair;


  chartcontrol1.legend.direction = legenddirection.lefttoright;
  chartcontrol1.legend.alignmenthorizontal = legendalignmenthorizontal.center;
  chartcontrol1.legend.alignmentvertical = legendalignmentvertical.bottomoutside;



  chartcontrol1.addtitle;
  }
  }
  }
}






namespace devexpresschart
{
  public static class chartutils
  {
  /// summary
  /// 增加数据筛选
  /// /summary
  /// 申博官方网站下载param name="seriesbase" series /param
  /// param name="columnname" 列名称 /param
  /// param name="value" 列名称对应的筛选数值 /param
  /// param name="datafiltercondition" datafiltercondition枚举 /param
  public static void adddatafilter
  {
  series.datafilters.add.fullname, datafiltercondition, value));
  }















  /// summary
  /// 设置x轴lable角度
  /// /summary
  /// param name="chart" chartcontrol /param
  /// param name="angle" 角度 /param
  public static void setxlableangle
  {
  xydiagram _xydiagram = chart.diagram;
  if
  _xydiagram.axisx.label.angle = angle;
  }
  /// summary
  ///  设置y轴lable角度
  /// /summary
  /// param name="chart" chartcontrol /param
  /// param name="angle" 角度 /param
  public static void setylableangle
  {
  xydiagram _xydiagram = chart.diagram;
  _xydiagram.axisy.label.angle = angle;
  }
  /// summary
  /// 设置coloreach
  /// /summary
  /// param name="chart" chartcontrol /param
  /// param name="coloreach" 是否设置成coloreach /param
  public static void setcoloreach
  {
  seriesviewcoloreachsupportbase coloreachview = series.view;
  if
  {
  coloreachview.coloreach = coloreach;
  }
  }
  /// summary
  /// 设置是否显示十字标线
  /// /summary
  /// param name="chart" chartcontrol /param
  /// param name="crosshair" 是否显示十字标线 /param
  public static void setcrosshair
  {
  chart.crosshairenabled = crosshair defaultboolean.true : defaultboolean.false;
  chart.crosshairoptions.showargumentlabels = crosshair;
  chart.crosshairoptions.showargumentline = crosshair;
  chart.crosshairoptions.showvaluelabels = crosshair;
  chart.crosshairoptions.showvalueline = crosshair;
  }
  /// summary
  /// 新增chartcontrol的title文字
  /// /summary
  /// param name="chart" chartcontrol /param
  /// param name="title" title文字 /param
  public static void addtitle
  {
  charttitle _title = new charttitle;
  _title.text = title;
  chart.titles.add;
  }
  /// summary
  /// 饼状series设置成百分比显示
  /// /summary
  /// param name="series" series /param
  public static void setpiepercentage
  {
  if
  {
  series.pointoptions).percentoptions.valueaspercent = true;
  series.pointoptions).valuenumericoptions.format = numericformat.percent;
  series.pointoptions).valuenumericoptions.precision = 0;
  }
  }
  }
}
运行效果:










































































希望本文所述对大家的c#程序设计有所帮助。

在线咨询
Copyright © 2018 申博网址申博网址-申博官方网站下载 All Rights Reserved