一、Series
Series 作为cartControl的基本单位来现实图表数据
所以每一个Series代表一种需要显示的类型。
首先实例化一个Series
Series serie = new Series(Caption, ViewType.Line); //ViewType是ChartControl图表类型的一个枚举器,其中Bar代表柱状图类型,通过修改ViewType的值可以实现跟换表格类型 series1.ArgumentScaleType = ScaleType.DateTime;//x轴类型 series1.ValueScaleType = ScaleType.Numerical;//y轴类型
series1.ArgumentDataMember = "StatisticsTime";//X轴的数据字段
series1.ValueDataMembers[0] = "StatisticsSum";//Y轴的数据字段
serie.ValueDataMembersSerializable = "VALUE";
series.CrosshairEnabled = DevExpress.Utils.DefaultBoolean.True;
LineSeriesView view = (LineSeriesView)serie.View;
series.CrosshairLabelPattern = "{S}:{A}:{V}"; //设置鼠标悬停后提示框显示格式 {S}-名称 {A}-X轴值 {V}-Y轴值
serie.CrosshairTextOptions.Font = new System.Drawing.Font("微软雅黑", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));//设置字体样式
view.LineMarkerOptions.Visible = false;//定义线条上点的标识形状是否需要
view.LineMarkerOptions.Kind = MarkerKind.Circle; //定义线条上点的标识形状
((LineSeriesView)series1.View).LineStyle.DashStyle = DashStyle.Solid;//线条的类型,虚线,实线
((PointSeriesLabel)series1.Label).Visible = false; //不显示X、Y轴上面的交点的值
二、XYDiagram
取出xy模式的 diagram , 因为这个sample 是选 xyDiagram 类型
XYDiagram xyDiagram = (XYDiagram)this.ChartBlance.Diagram; xyDiagram.AxisX.AutoScaleBreaks.Enabled = true; xyDiagram.AxisX.AutoScaleBreaks.MaxCount = 8; xyDiagram.AxisX.DateTimeScaleOptions.AggregateFunction = DevExpress.XtraCharts.AggregateFunction.Custom;//自订格式 xyDiagram.AxisX.DateTimeScaleOptions.MeasureUnit = DevExpress.XtraCharts.DateTimeMeasureUnit.Minute;//设定时间区间大小 xyDiagram.AxisX.Interlaced = true; xyDiagram.AxisX.Label.Font = new System.Drawing.Font("微软雅黑", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); xyDiagram.AxisX.MinorCount = 5; xyDiagram.AxisX.Visibility = DevExpress.Utils.DefaultBoolean.True; xyDiagram.AxisX.VisibleInPanesSerializable = "-1";