MultiLineXAxisLabelProvider.cs 1.0 KB

123456789101112131415161718192021222324252627282930313233
  1. using Aitex.Core.RT.IOCore;
  2. using SciChart.Charting.Visuals.Axes.LabelProviders;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.ComponentModel;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. namespace MECF.Framework.UI.Client.Converter
  10. {
  11. public class MultiLineXAxisLabelProvider : NumericLabelProvider
  12. {
  13. private DateTime _firstTime=DateTime.MinValue;
  14. public MultiLineXAxisLabelProvider(DateTime time)
  15. {
  16. _firstTime = time;
  17. }
  18. public override string FormatLabel(IComparable dataValue)
  19. {
  20. if (dataValue is double xValue &&xValue>=0)
  21. {
  22. long t = Convert.ToInt64(xValue * 10);//保留1位小数
  23. // 返回两行文本,用换行符分隔
  24. return $"{t / 36000:D2}:{(t % 36000) / 600:D2}:{(t % 600) / 10d:00.#}\n{_firstTime.AddSeconds(t / 10d):HH:mm:ss.F}";
  25. }
  26. return base.FormatLabel(dataValue);
  27. }
  28. }
  29. }