devexpress图表Chart开发日志


Legend设置

控制
chartControl1.Legend.Direction = LegendDirection.LeftToRight;
chartControl1.Legend.AlignmentVertical = LegendAlignmentVertical.TopOutside;
chartControl1.Legend.AlignmentHorizontal = LegendAlignmentHorizontal.Left;

说明:

Direction

LegendDirection.TopToBottom
LegendDirection.BottomToTop
LegendDirection.LeftToRight
LegendDirection.RightToLeft

AlignmentVertical

LegendAlignmentVertical.TopOutside
LegendAlignmentVertical.Top
LegendAlignmentVertical.Center
LegendAlignmentVertical.Bottom
LegendAlignmentVertical.BottomOutside

 

AlignmentHorizontal

LegendAlignmentHorizontal.LeftOutside
LegendAlignmentHorizontal.Left
LegendAlignmentHorizontal.Center
LegendAlignmentHorizontal.Right
LegendAlignmentHorizontal.RightOutside
 
 

标题 Title

C# 全选
DevExpress.XtraCharts.ChartTitle chartTitle1 = new DevExpress.XtraCharts.ChartTitle(); chartTitle1.Font = new System.Drawing.Font("Tahoma", 18F, System.Drawing.FontStyle.Bold);
chartTitle1.Text = "2021年统计图";
chartTitle1.Visibility = DevExpress.Utils.DefaultBoolean.True;
this.chartControl1.Titles.AddRange(new DevExpress.XtraCharts.ChartTitle[] {chartTitle1});

devexpress图表Chart开发日志

隐藏 Legend

C# 全选
this.chartControl1.Legend.Visibility = DevExpress.Utils.DefaultBoolean.False;

devexpress图表Chart开发日志

devexpress图表Chart开发日志

显示Series值 Label

C# 全选
series1.LabelsVisibility = DevExpress.Utils.DefaultBoolean.True;

devexpress图表Chart开发日志

Series值 Label 控制属性

C# 全选
// 显示Label
series2.LabelsVisibility = DevExpress.Utils.DefaultBoolean.True;
// 对齐方式,左对齐,右对齐,居中对齐
series2.Label.TextAlignment = StringAlignment.Center;
// 文本方向,横向,竖向
series2.Label.TextOrientation = TextOrientation.Horizontal;
// Label位置,条形图
(series2.Label as BarSeriesLabel).Position = BarSeriesLabelPosition.Top;

devexpress图表Chart开发日志

示例:

效果图:
代码:
chartControl1.Legend.Direction = LegendDirection.LeftToRight;
chartControl1.Legend.AlignmentVertical = LegendAlignmentVertical.TopOutside;
chartControl1.Legend.AlignmentHorizontal = LegendAlignmentHorizontal.Left;
完整代码:
/// <summary>
/// 显示图表
/// </summary>
private void DoRefreshChart(string category, List<TreeTableModel> data)
{
    chartControl1.Series.Clear();
    List<Series> SeriesList = new List<Series>();
    Series seriesMy = new Series(category, ViewType.Spline);//曲线
    Series seriesAvg = new Series("同行同层平均" + category, ViewType.Spline);//曲线
    Series seriesGood = new Series("同行同层优秀" + category, ViewType.Spline);//曲线

    foreach (var p in data)
    {
        seriesMy.Points.Add(new SeriesPoint(p.Label, p.Value));
        seriesAvg.Points.Add(new SeriesPoint(p.Label, p.ValueAvg));
        seriesGood.Points.Add(new SeriesPoint(p.Label, p.ValueGood));
    }

    SetCommonOption(seriesMy);
    SetCommonOption(seriesAvg);
    SetCommonOption(seriesGood);

    SeriesList.Add(seriesMy);
    SeriesList.Add(seriesAvg);
    SeriesList.Add(seriesGood);

    chartControl1.Series.AddRange(SeriesList.ToArray());

    XYDiagram diagram = (XYDiagram)chartControl1.Diagram;

    diagram.AxisX.Title.Visibility = DevExpress.Utils.DefaultBoolean.False;
    diagram.AxisX.Title.Alignment = StringAlignment.Center;
    diagram.AxisX.Title.Text = "日期";
    diagram.AxisX.Title.EnableAntialiasing = DevExpress.Utils.DefaultBoolean.True;
    diagram.AxisX.Title.Font = new Font("Tahoma", 12, FontStyle.Bold);
    diagram.AxisX.NumericScaleOptions.GridSpacing = 60;
    diagram.AxisX.Label.Visible = true;

    diagram.AxisY.Title.Visibility = DevExpress.Utils.DefaultBoolean.False; ;
    diagram.AxisY.Title.Alignment = StringAlignment.Center;
    diagram.AxisY.Title.Text = "数值";
    diagram.AxisY.Title.EnableAntialiasing = DevExpress.Utils.DefaultBoolean.True; ;
    diagram.AxisY.Title.Font = new Font("Tahoma", 12, FontStyle.Bold);

    chartControl1.Legend.Direction = LegendDirection.LeftToRight;
    chartControl1.Legend.AlignmentVertical = LegendAlignmentVertical.TopOutside;
    chartControl1.Legend.AlignmentHorizontal = LegendAlignmentHorizontal.Left;

}
GarsonZhang www.yesdotnet.com

 

版权声明:本文为YES开发框架网发布内容,转载请附上原文出处连接
YES开发框架
上一篇:解决winform使用EF6 第一次查询会慢个几秒钟
下一篇:C# CefSharp的使用
评论列表

发表评论

评论内容
昵称:
关联文章

devexpress图表Chart开发
20210910 更新
20210904 更新
20210909 更新
更新
更新
20210901 更新
20210904 更新
20210906 更新
20210907 更新
20210908 更新
20210913 更新
20210914 更新
20210922 更新
20210930 更新
更新
202111 更新
.NET Core MVC中间件使用记录
DevExpress 设置DateEdit显示年月
Winform开发框架日志管理

联系我们
联系电话:15090125178(微信同号)
电子邮箱:garson_zhang@163.com
站长微信二维码
微信二维码