Xamarin图表开发基础教程(4)OxyPlot框架

XamaminAndroid中绘制线图OxyPlotAndroidDemo

【示例1-1:OxyPlotAndroidDemo】下面实现线图的绘制。具体的操作步骤如下:

(1)打开Xamarin.Android项目。

(2)将OxyPlot.Xamarin.Android组件添加到项目中的引入中。

(3)打开activity_main.axml文件,使用PlotView进行布局。代码如下:

<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"xmlns:app="http://schemas.android.com/apk/res-auto"xmlns:tools="http://schemas.android.com/tools"android:layout_width="match_parent"android:layout_height="match_parent"><OxyPlot.Xamarin.Android.PlotViewandroid:id="@+id/plot_view"android:layout_width="match_parent"android:layout_height="match_parent"/></RelativeLayout>

(4)打开MainActivity.cs文件,在此文件中实现剩余的步骤,即绘制图表并设置显示模式。代码如下:

using Android.App;using Android.OS;using Android.Support.V7.App;using Android.Runtime;using Android.Widget;using OxyPlot.Xamarin.Android;using OxyPlot;using OxyPlot.Axes;using OxyPlot.Series;namespace OxyPlotAndroidDemo{[Activity(Label = "@string/app_name", Theme = "@style/AppTheme", MainLauncher = true)]public class MainActivity : AppCompatActivity{protected override void OnCreate(Bundle savedInstanceState){base.OnCreate(savedInstanceState);// Set our view from the "main" layout resourceSetContentView(Resource.Layout.activity_main);PlotView view = FindViewById<PlotView>(Resource.Id.plot_view);view.Model = CreatePlotModel();                                                       //设置显示模式}//绘制图表private PlotModel CreatePlotModel(){//创建图表模式var plotModel = new PlotModel{Title = "OxyPlot Demo"};//添加坐标轴plotModel.Axes.Add(new LinearAxis { Position = AxisPosition.Bottom });plotModel.Axes.Add(new LinearAxis { Position = AxisPosition.Left, Maximum = 10, Minimum = 0 });//创建数据列var series1 = new LineSeries{Title= "Data",MarkerType = MarkerType.Circle,MarkerSize = 4,MarkerStroke = OxyColors.White};//添加数据点series1.Points.Add(new DataPoint(0.0, 6.0));series1.Points.Add(new DataPoint(1.4, 2.1));series1.Points.Add(new DataPoint(2.0, 4.2));series1.Points.Add(new DataPoint(3.3, 2.3));series1.Points.Add(new DataPoint(4.7, 7.4));series1.Points.Add(new DataPoint(6.0, 6.2));series1.Points.Add(new DataPoint(8.9, 8.9));//添加数据列plotModel.Series.Add(series1);return plotModel;}}}

运行程序,显示的图表如图1.1所示。

图1.1  Xamarin.Android平台的线图效果标题

Xamarin图表开发基础教程(4)OxyPlot框架相关推荐

  1. Xamarin图表开发基础教程(13)OxyPlot框架支持的其它图表

    Xamarin图表开发基础教程(13)OxyPlot框架支持的其它图表 除了以上提到的图表外,OxyPlot组件还包含了6种类型的其它图表,分别为等高线图.箱线图.饼图.热图.散点图和散点误差图,如图 ...

  2. Xamarin图表开发基础教程(12)OxyPlot框架支持的金融图表类型

    Xamarin图表开发基础教程(12)OxyPlot框架支持的金融图表类型 OxyPlot组件中支持5种类型的金融图表,它们分别为销量图.高低图.股票K线图.股票走势图和旧式股票图,如图1.20~1. ...

  3. Xamarin图表开发基础教程(11)OxyPlot框架支持的图表类型

    Xamarin图表开发基础教程(11)OxyPlot框架支持的图表类型 OxyPlot组件中支持7种类型的条型图表,分别为普通条形图.线型条形图.矩形条形图.差值图.龙卷风图.普通柱形图和柱形误差图, ...

  4. Xamarin图表开发基础教程(10)OxyPlot框架支持的图表类型

    Xamarin图表开发基础教程(10)OxyPlot框架支持的图表类型 OxyPlot组件支持26种图表,这些图表按照功能和样式可以分为4大类,分别为线型图表.条型图表.金融图表和其它图表. 线型图表 ...

  5. Xamarin图表开发基础教程(8)OxyPlot框架

    Xamarin图表开发基础教程(8)OxyPlot框架 [示例OxyPlotFormsDemo]在Xamarin.Forms中实现线图的显示. (1)打开Xamarin.Forms项目. (2)将Ox ...

  6. Xamarin图表开发基础教程(7)OxyPlot框架

    Xamarin图表开发基础教程(7)OxyPlot框架 Xamarin.Forms中使用OxyPlot框架 在Xamarin. Forms平台上实现图表显示需要完成以下的步骤: 1.添加OxyPlot ...

  7. Xamarin图表开发基础教程(6)OxyPlot框架

    Xamarin图表开发基础教程(6)OxyPlot框架 Xamamin iOS中绘制线图OxyPlotiOSDemo [示例OxyPlotiOSDemo]下面将实现线图的显示.具体的操作步骤如下: ( ...

  8. Xamarin图表开发基础教程(5)OxyPlot框架

    Xamarin图表开发基础教程(5)OxyPlot框架 Xamarin.iOS中使用OxyPlot框架 在Xamarin.iOS平台上实现图表显示需要完成以下的步骤: 1.添加OxyPlot.Xama ...

  9. Xamarin图表开发基础教程(3)OxyPlot框架

    Xamarin图表开发基础教程(3)OxyPlot框架 Xamarin.Android中使用OxyPlot框架 在Xamarin.Android平台上实现图表显示需要完成以下的步骤: 1.添加OxyP ...

最新文章

  1. 类似ngnix的多进程监听用例
  2. HTML 特殊符号编码对照表
  3. 离散数学 第二章 谓词逻辑 2-1 谓词的概念与表示
  4. Python---Pickle模块
  5. FPGA与MCU,DSP(如C6000,C5000等)等设计思想的异同
  6. HDFS无法对大量小文件进行存储
  7. windows安装MySQL数据库【附安装文档和安装包】
  8. 数据治理需要注意什么问题
  9. 整合阿里云视频播放器——Coding在线(十四)
  10. Android学习资料整理
  11. log4rs日志库简析
  12. RestTemplate和ResponseEntity
  13. 新浪cn邮箱设置收件和发件服务器信息,新浪cn邮箱如何设置
  14. alpha测试和beta测试
  15. android桌面 文件夹路径是什么原因,安卓系统桌面快捷方式默认在哪个文件夹
  16. Java 第一个程序Hello
  17. 这样的人注定生活在社会最底层
  18. 结构力学计算机算法,05结构力学第八章渐近法及其他算法概述.ppt
  19. 百度搜索限定时间_几个方法教你用好手中的搜索,提高搜索效率和质量
  20. 高中计算机手抄报图片大全集,高中优秀手抄报图片

热门文章

  1. No serializer found for class org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer解决方法
  2. 解决IOS滑动页面fixed浮动问题
  3. 解决(springboot项目)mysql表名大写,造成jpa Table doesn‘t exist问题
  4. 解决VS2015安装Android SDK 后文件不全及更新问题
  5. 解决eclipse报PermGen space异常的问题
  6. 如何在C#Windows控制台应用程序中更新当前行?
  7. 如何从“查找”中排除所有“拒绝权限”消息?
  8. 参考-这个符号在PHP中是什么意思?
  9. 聊聊flink的OperatorStateBackend
  10. 解决莫名其妙出现connection closed的错误