using DevExpress.Charts.Native; using DevExpress.XtraCharts; using DevExpress.XtraEditors; using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Diagnostics; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using DW5S.DTO; namespace DW5S.App.UserControl { public partial class CtrlDraw : DevExpress.XtraEditors.XtraUserControl { public CtrlDraw() { InitializeComponent(); } private void CtrlDraw_Load(object sender, EventArgs e) { chartControl1.Legend.AlignmentVertical = LegendAlignmentVertical.Top;//图例位置 XYDiagram diagram = (XYDiagram)chartControl1.Diagram; //diagram.AxisX.Label.Staggered = true;//X轴坐标交错排列 diagram.AxisX.Label.EnableAntialiasing = DevExpress.Utils.DefaultBoolean.True;//抗锯齿 diagram.AxisY.Label.EnableAntialiasing = DevExpress.Utils.DefaultBoolean.True;//抗锯齿 diagram.AxisY.Label.TextPattern = "{V:f3}us"; diagram.AxisX.WholeRange.AutoSideMargins = true;//是否从X轴原点开始显示 DrawDto dto = new DrawDto() { ImageName = "时差趋势图20240910120000", //MaxX = 1024, //MaxY = 10000, PointX = new object[5000], PointY = new double[5000], }; Random r = new Random(); Stopwatch sw = new Stopwatch(); sw.Start(); SeriesPoint[] sps = new SeriesPoint[5000]; for (int i = 0; i < 5000; i++) { sps[i] = new SeriesPoint(); dto.PointX[i] = (double)r.Next(10, 10000); dto.PointY[i] = r.Next(1000, 9000); sps[i].NumericalArgument = (double)dto.PointX[i]; sps[i].Values = new double[1] { dto.PointY[i] }; } chartControl1.Series[0].Points.AddRange(sps); sw.Stop(); var dd = sw.ElapsedMilliseconds; } } }