CtrlDraw.cs 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. using DevExpress.Charts.Native;
  2. using DevExpress.XtraCharts;
  3. using DevExpress.XtraEditors;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.ComponentModel;
  7. using System.Data;
  8. using System.Diagnostics;
  9. using System.Drawing;
  10. using System.Linq;
  11. using System.Text;
  12. using System.Threading.Tasks;
  13. using System.Windows.Forms;
  14. using DW5S.DTO;
  15. namespace DW5S.App.UserControl
  16. {
  17. public partial class CtrlDraw : DevExpress.XtraEditors.XtraUserControl
  18. {
  19. public CtrlDraw()
  20. {
  21. InitializeComponent();
  22. }
  23. private void CtrlDraw_Load(object sender, EventArgs e)
  24. {
  25. chartControl1.Legend.AlignmentVertical = LegendAlignmentVertical.Top;//图例位置
  26. XYDiagram diagram = (XYDiagram)chartControl1.Diagram;
  27. //diagram.AxisX.Label.Staggered = true;//X轴坐标交错排列
  28. diagram.AxisX.Label.EnableAntialiasing = DevExpress.Utils.DefaultBoolean.True;//抗锯齿
  29. diagram.AxisY.Label.EnableAntialiasing = DevExpress.Utils.DefaultBoolean.True;//抗锯齿
  30. diagram.AxisY.Label.TextPattern = "{V:f3}us";
  31. diagram.AxisX.WholeRange.AutoSideMargins = true;//是否从X轴原点开始显示
  32. DrawDto dto = new DrawDto()
  33. {
  34. ImageName = "时差趋势图20240910120000",
  35. //MaxX = 1024,
  36. //MaxY = 10000,
  37. PointX = new object[5000],
  38. PointY = new double[5000],
  39. };
  40. Random r = new Random();
  41. Stopwatch sw = new Stopwatch();
  42. sw.Start();
  43. SeriesPoint[] sps = new SeriesPoint[5000];
  44. for (int i = 0; i < 5000; i++)
  45. {
  46. sps[i] = new SeriesPoint();
  47. dto.PointX[i] = (double)r.Next(10, 10000);
  48. dto.PointY[i] = r.Next(1000, 9000);
  49. sps[i].NumericalArgument = (double)dto.PointX[i];
  50. sps[i].Values = new double[1] { dto.PointY[i] };
  51. }
  52. chartControl1.Series[0].Points.AddRange(sps);
  53. sw.Stop();
  54. var dd = sw.ElapsedMilliseconds;
  55. }
  56. }
  57. }