首页 > 其他 > 详细

原创:DynamicDataDisplay波形显示自定义格式

时间:2019-05-17 16:08:56      阅读:684      评论:0      收藏:0      [点我收藏+]

原创:DynamicDataDisplay 原版本在日期显示的格式上与我们的习惯不一样,特做如下修改:

技术分享图片

自定义日期格式修改:

//MainWindow.cs中
            var ds = new EnumerableDataSource<VoltagePoint>(voltagePointCollection);
            ds.SetXMapping(x => dateAxis.ConvertToDouble(x.Date));
            ds.SetYMapping(y => y.Voltage);
            plotter.AddLineGraph(ds, Colors.Green, 2, "Temperature"); // to use this method you need "using Microsoft.Research.DynamicDataDisplay;"
            MaxVoltage = 40;
            MinVoltage = 0;
            plotter.AxisGrid.BorderBrush = new SolidColorBrush(Color.FromRgb(50,50,0));
            dateAxis.LabelProvider.LabelStringFormat = "HH:mm:ss";
            
            cursorCoordinateGraph.XTextMapping = x =>
            {
                if (Double.IsNaN(x))
                    return "";

                DateTime time = dateAxis.ConvertFromDouble(x);
                return time.ToString("HH:mm:ss");
            };

LabelProviderBase.cs:

        protected virtual string GetString(LabelTickInfo<T> tickInfo)
        {
            string text = null;
            if (CustomFormatter != null)
            {
                text = CustomFormatter(tickInfo);
            }
            if (text == null)
            {
                text = GetStringCore(tickInfo);

                if (text == null)
                    throw new ArgumentNullException(Properties.Resources.TextOfTickShouldNotBeNull);
            }
            if (LabelStringFormat != null && LabelStringFormat.Length > 0)
            {
                //text = String.Format(LabelStringFormat, text);
                if (tickInfo.Tick is System.DateTime)
                {
                    text = Convert.ToDateTime(tickInfo.Tick).ToString(LabelStringFormat);
                }
                else
                {
                    text = String.Format(LabelStringFormat, tickInfo.Tick);
                }
            }

            return text;
        }

修改底下的标签:

技术分享图片

 

原创:DynamicDataDisplay波形显示自定义格式

原文:https://www.cnblogs.com/youmeetmehere/p/10881799.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!