设为首页 - 加入收藏 ASP站长网(Aspzz.Cn)- 科技、建站、经验、云计算、5G、大数据,站长网!
热搜: 创业者 手机 数据
当前位置: 首页 > 服务器 > 系统 > 正文

DevExpress20:XtraCharts控件实现图表(3)

发布时间:2021-01-07 01:10 所属栏目:52 来源:网络整理
导读:四、事件 1、CustomDrawAxisLabel : 接管此事件来获得轴标签。定制轴标签 void chartControl1_CustomDrawAxisLabel( sender,CustomDrawAxisLabelEventArgs e){ AxisBase axis = e.Item.Axis; if (axis is AxisY ||

DevExpress20:XtraCharts控件实现图表


四、事件

1、CustomDrawAxisLabel : 接管此事件来获得轴标签。定制轴标签

void chartControl1_CustomDrawAxisLabel( sender,CustomDrawAxisLabelEventArgs e) { AxisBase axis = e.Item.Axis; if (axis is AxisY || axis is AxisY3D || axis RadarAxisY) { double axisValue = (double)e.Item.AxisValue; if (axisValue < ) { e.Item.TextColor = Color.Red; } else if (axisValue > ) { e.Item.Text = +" + e.Item.Text; e.Item.TextColor = Color.Green; } if (axisValue == Zero; } } }

2、ObjectHotTracked:鼠标指针悬停位置

void chartControl1_ObjectHotTracked(if (e.AdditionalObject AxisTitle) { MessageBox.Show(e.AdditionalObject.GetType().ToString()); } }

3、CustomDrawSeries :自定义绘制系列

void chartControl1_CustomDrawSeries( Find all Bar Series by their view type,and fill them with Aqua color. if (e.Series.View BarSeriesView) e.SeriesDrawOptions.Color = Color.Aqua; Find the series by its name,and change its line style to dash-dot-dot. (Here it‘s assumed that the series view type is LineSeriesView). if (e.Series.Name == Line Series) ((LineDrawOptions)e.SeriesDrawOptions).LineStyle.DashStyle = DevExpress.XtraCharts.DashStyle.DashDotDot; Find all Point Series by the type of its DrawOptions,and change their marker kind to diamond. if (e.SeriesDrawOptions.GetType() == (PointDrawOptions)) ((PointDrawOptions)e.SeriesDrawOptions).Marker.Kind = MarkerKind.Diamond; }

4、CustomDrawSeriesPoint:自定义绘制系列点

void chartControl1_CustomDrawSeriesPoint( These changes will be applied to Bar Series only. BarDrawOptions drawOptions = e.SeriesDrawOptions as BarDrawOptions; if (drawOptions == ) ; Get the fill options for the series point. drawOptions.FillStyle.FillMode = DevExpress.XtraCharts.FillMode.Gradient; RectangleGradientFillOptions options = drawOptions.FillStyle.Options RectangleGradientFillOptions; if (options == Get the value at the current series point. double val = e.SeriesPoint[]; If the value is less than 1,hide the point‘s label. if (e.SeriesPoint[0] < 1) { e.LabelText = ; } If the value is less than 2.5,then fill the bar with green colors. if (val < 2.5) { options.Color2 = Color.FromArgb(154,128);">196,128);">84); drawOptions.Color = Color.FromArgb(81,128);">137,128);">3); drawOptions.Border.Color = Color.FromArgb(100,128);">39,128);">91,0);">); } ... if the value is less than 5.5,then fill the bar with yellow colors. 5.5254,128);">233,128);">124249,128);">170,128);">1560,128);">165,128);">73,128);">5 ... if the value is greater,then fill the bar with red colors. { options.Color2 = Color.FromArgb(242,128);">143,128);">112199,128);">57,128);">12155,128);">26,0);">); } }

五、导出

1、导出为PDF:

图表会被自动拆分,

if (chartControlidx.IsPrintingAvailable) 是否能被打印或输出 { Exports to a PDF file. chartControlidx.ExportToPdf(path); Exports to a stream as PDF. System.IO.FileStream pdfStream = System.IO.FileStream(path,System.IO.FileMode.Create); chartControlidx.ExportToPdf(pdfStream); ... pdfStream.Close(); }

2、导出为图像文件:

{ Create an image in the specified format from the chart and save it to the specified path. chartControlidx.ExportToImage(path,System.Drawing.Imaging.ImageFormat.Png); png格式 }

六、参考

https://www.cnblogs.com/Mr-Li-2016/p/6115089.html

(编辑:ASP站长网)

网友评论
推荐文章
    热点阅读