using DevExpress.XtraCharts;
|
using Yw.WinFrmUI.Phart;
|
|
namespace HStation.WinFrmUI
|
{
|
public partial class PerformChart : DevExpress.XtraEditors.XtraForm
|
{
|
public PerformChart()
|
{
|
InitializeComponent();
|
this.chartControl1.SetChartBackColor();
|
}
|
|
public class DataPoint
|
{
|
public DataPoint(double x, double y)
|
{
|
X = x;
|
Y = y;
|
}
|
|
public double X { get; set; }
|
public double Y { get; set; }
|
}
|
|
public void SetBindingData(List<DataPoint> dataPoint, string xTitle = "X轴", string yTitle = "Y轴")
|
{
|
var series = this.chartControl1.GetSeriesByName("SeriesPoint");
|
series.DataSource = dataPoint;
|
series.ArgumentScaleType = ScaleType.Numerical;
|
series.ArgumentDataMember = "X";
|
series.ValueScaleType = ScaleType.Numerical;
|
series.ValueDataMembers.AddRange(new string[] { "Y" });
|
chartControl1.Series.Add(series);
|
XYDiagram diagram = (XYDiagram)chartControl1.Diagram;
|
//X轴
|
diagram.AxisX.Title.Visible = true;
|
diagram.AxisX.Title.Text = xTitle;
|
diagram.AxisX.Title.TextColor = Color.DodgerBlue;
|
diagram.AxisX.Label.TextColor = Color.DodgerBlue;
|
diagram.AxisX.Title.Font = new Font("Tahoma", 12, FontStyle.Regular);
|
//Y轴
|
diagram.AxisY.Title.Visible = true;
|
diagram.AxisY.Title.Text = yTitle;
|
diagram.AxisY.Title.TextColor = Color.Crimson;
|
diagram.AxisY.Label.TextColor = Color.Crimson;
|
diagram.AxisY.Title.Font = new Font("Tahoma", 12, FontStyle.Regular);
|
}
|
}
|
}
|