您的位置:首页 > 教育 > 培训 > 济南房地产网app下载_品牌策划公司推荐_网站推广怎样做_seowhy论坛

济南房地产网app下载_品牌策划公司推荐_网站推广怎样做_seowhy论坛

2024/10/6 21:23:06 来源:https://blog.csdn.net/weixin_44291381/article/details/142256210  浏览:    关键词:济南房地产网app下载_品牌策划公司推荐_网站推广怎样做_seowhy论坛
济南房地产网app下载_品牌策划公司推荐_网站推广怎样做_seowhy论坛

方法:

InitTable 方法:负责初始化图表模型,包括设置图表的样式、坐标轴、系列和注释。这个方法包括多个 Init 方法的调用,表示图表的初始化过程可以分步骤进行。
InitGoalPoint 方法:当前未实现,但预留了子类进行重写。
InitXInitY 方法:分别初始化 X 和 Y 轴。
AddPoint 方法:向图表中添加点,并更新 Y 轴的最大值。
ClearPoint 方法:清空图表中的点并重新绘制。

字段和属性:

使用了 protected 修饰符来保护图表的各个部分(如 X 轴、Y 轴、系列等),允许子类访问和修改。
DataSrc 是一个公开的字典,用于存储数据源。
ChartModel 是公开的,只读属性,返回当前的图表模型。
GoalLines 也是公开的,只读属性,返回目标线的集合。

    [AddINotifyPropertyChangedInterface]public abstract class ChartBase<T>{public ChartBase(){InitTable();}protected virtual string ChartName { get; set; } = "";protected virtual string ChartXName { get; set; } = "";protected virtual string ChartYName { get; set; } = "";protected virtual double ChartXMin { get; set; } = double.NaN;protected virtual double ChartXMax { get; set; } = double.NaN;protected virtual double ChartXStep { get; set; } = double.NaN;protected virtual double ChartYMin { get; set; } = double.NaN;protected virtual double ChartYMax { get; set; } = double.NaN;protected virtual double ChartYStep { get; set; } = double.NaN;protected virtual void InitTable(){DataSrc = new();chartModel = new PlotModel(){Title = ChartName,IsLegendVisible = true,LegendMargin = 5,LegendPlacement = LegendPlacement.Outside,LegendOrientation = LegendOrientation.Horizontal,LegendPosition = LegendPosition.TopLeft,LegendFontSize = 15,PlotAreaBorderThickness = new OxyThickness(1, 0, 0, 1),TextColor = foreground,TitleColor = foreground,PlotAreaBorderColor = foreground,};InitX();InitY();InitGoalLine();InitGoalPoint();if(chart_X != null){ChartModel.Axes.Add(chart_X);}if (chart_Y != null){ChartModel.Axes.Add(chart_Y);}if(chart_X != null && chart_Y != null){lineSeries = new LineSeries(){//IsVisible = isShowAcResistance,//Title = "奈奎斯特图",MarkerType = MarkerType.Circle,MarkerFill = OxyColors.Transparent,MarkerStroke = OxyColors.DarkSeaGreen,MarkerStrokeThickness = 1,//StrokeThickness = seriesStrokeThickness,Color = OxyColors.CadetBlue,TextColor = foreground,XAxisKey = "Chart_X",YAxisKey = "Chart_Y",};ChartModel.Series.Add(lineSeries);}if(goalPoints!=null){ChartModel.Series.Add(goalPoints);}if(goalLines!=null){goalLines.ForEach(x => ChartModel.Annotations.Add(x));}}protected virtual void InitGoalPoint(){}OxyColor foreground = OxyColors.White;protected virtual void InitGoalLine(){//goalLines = new List<LineAnnotation>();//goalLines.Add(new LineAnnotation()//{//    Type = LineAnnotationType.Horizontal,//    Y = 20,//    LineStyle = LineStyle.Dash,//    StrokeThickness = 2,//    Color = OxyColors.DeepPink,//    TextColor = OxyColors.DeepPink,//    Text = "20",//});}protected virtual void InitY(){chart_Y = new LinearAxis(){Position = AxisPosition.Left,Title = ChartYName,TitlePosition = 0.5,Minimum = ChartYMin,Maximum = ChartYMax,MajorStep = ChartYStep,TextColor = foreground,TitleColor = foreground,TicklineColor = foreground,MinorTicklineColor = foreground,IsZoomEnabled = true,IsPanEnabled = true,Key = "Chart_Y",};}protected virtual void InitX(){chart_X = new LinearAxis(){Position = AxisPosition.Bottom,Title = ChartXName,Minimum = ChartXMin,Maximum = ChartXMax,MajorStep = ChartXStep,TextColor = foreground,TitleColor = foreground,TicklineColor = foreground,MinorTicklineColor = foreground,IsZoomEnabled = true,IsPanEnabled = true,Key = "Chart_X",};}public virtual void AddPoint(double x,double y){lineSeries.Points.Add(new(x,y));if(y > ChartModel.Axes[1].Maximum){ChartModel.Axes[1].Maximum = y + 2;}chartModel.InvalidatePlot(true);}public virtual void ClearPoint(){lineSeries.Points.Clear();if(goalPoints!=null){goalPoints.Points.Clear();}chartModel.InvalidatePlot(true);}//public void SetGoalLine1(double goal)//{//    goalLines[0].Y = goal;//    goalLines[0].Text = goal.ToString();//    chartModel.InvalidatePlot(true);//}//public void SetGoalPoint(double x, double y)//{//    goalPoints.Points.Add(new ScatterPoint(x, y));//    chartModel.InvalidatePlot(true);//}protected LinearAxis chart_X = null;protected LinearAxis chart_Y = null;protected LineSeries lineSeries = null;protected List<LineAnnotation> goalLines = null;protected ScatterSeries goalPoints = null;protected PlotModel chartModel;public Dictionary<int, T> DataSrc;public PlotModel ChartModel { get => chartModel; }public List<LineAnnotation> GoalLines { get => goalLines; }}

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com