, Xamarin的图表开发基础教程(3)OxyPlot框架
Xamarin.Android中使用
在Xamarin.Android平台上实现图表显示需要完成以下的步骤:
1。添加OxyPlot.Xamarin.Android组件
打开Xamarin.Android项目,使用Nuget将OxyPlot.Xamarin.Android组件添加到项目的引入中。
2。布局PlotView视图
在界面布局axml文件中,使用PlotView视图进行布的局,其语法形式如下:
<强> & lt; OxyPlot.Xamarin.Android.PlotView 强>
<>强,,,,android: id=? * * * * * * *“强>
<>强,,,,android: layout_width=? * * * * * * * * * *“强>
<强> android: layout_height=? * * * * * * * * * *“强>
<强>……,/在强>
注意:PlotView视图是一个视图控件,用于显示图表。
3。构建图表
使用PlotModel类构建图表,该类被称为图表模型。开发者可以将其理解为一个绘制图表的画布。可以根据需求,将坐标轴以及数据列添加到画布中,即实现绘制。
4。显示图表
将PlotView视图的显示模式模式设置为PlotModel对象,即设置PlotView视图需要显示的内容。这样就可以完成图表的显示。