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

Xamamin iOS中绘制线图OxyPlotiOSDemo

【示例OxyPlotiOSDemo】下面将实现线图的显示。具体的操作步骤如下:

(1)打开Xamarin.iOS项目。

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

(3)打开ViewController.cs文件,完成剩余的步骤,即创建PlotView视图、绘制图表、设置显示模式以及显示PlotView。代码如下:

using Foundation;

using System;

using UIKit;

using OxyPlot.Xamarin.iOS;

using OxyPlot;

using OxyPlot.Axes;

using OxyPlot.Series;

namespace OxyPlotiOSDemo

{

    public partial class ViewController : UIViewController

    {

        public ViewController (IntPtr handle) : base (handle)

        {

        }

        public override void ViewDidLoad ()

        {

            base.ViewDidLoad ();

            // Perform any additional setup after loading the view, typically from a nib.

            //创建PlotView视图

            PlotView plotView = new PlotView

            {

                Frame = this.View.Frame

            };

            plotView.Model=CreatePlotModel();                                                    //设置显示模式

            this.View.Add(plotView);                                                                        //将PlotView视图添加到主视图上

        }

        //绘制图表

        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.2所示的效果。

图1.2  Xamarin.iOS平台的线图效果

Xamarin图表开发基础教程(6)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图表开发基础教程(9)OxyPlot框架

    Xamarin图表开发基础教程(9)OxyPlot框架 OxyPlot组件构成 OxyPlot组件主要由两个类构成,分别为PlotView和PlotModel.这两个类我们在上文中也使用到了.本节将讲 ...

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

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

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

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

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

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

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

    Xamarin图表开发基础教程(4)OxyPlot框架 XamaminAndroid中绘制线图OxyPlotAndroidDemo [示例1-1:OxyPlotAndroidDemo]下面实现线图的绘 ...

随机推荐

  1. Xmind8安装和破解(Windows下)

    如果本文对你有用,请爱心点个赞,提高排名,帮助更多的人.谢谢大家!❤ 如果解决不了,可以在文末进群交流. 一.准备工作:软件.补丁下载及安装  Xmind8官方下载地址:https://www.xmi ...

  2. PHP、JS 中 encode/decode

    PHP : urlencode() urldecode() JS : encodeURIComponent() decodeURIComponent() 同一字符串,编码后的结果一样 1

  3. 教你如何配置linux用户实现禁止ssh登陆机器但可用sftp登录!

    构想和目标最近有个这样的诉求:基于对线上服务器的保密和安全,不希望开发人员直接登录线上服务器,因为登录服务器的权限太多难以管控,如直接修改代码.系统配置,并且也直接连上mysql.因此希望能限制开发人 ...

  4. 【Code Tools】AB性能测试工具(二)

    一.测试Get请求 1.每次并发请求10个,总共1000个请求 ab -n -c https://www.baidu.com/ 2.指定Header参数 通过-H来指定 ab -n -c -H 'Ac ...

  5. linux内核makefile概览

    linux内核makefile概览 本博客参照内核官方英文文档 linux的内核makefile主要用于编译整个内核源码,按照用户的需求生成各种目标文件,对于用户来说,编译内核时非常简单的,只需要几个 ...

  6. Python的logging模块详解

          Python的logging模块详解 作者:尹正杰  版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.日志级别 日志级别指的是产生的日志的事件的严重程度. 设置一个级别后,严重程度 ...

  7. nginx-location语法匹配优先级

  8. delete properties inside object

  9. jQuery 查找和过滤

    通常情况下选择器可以直接定位到我们想要的元素,但是,当我们拿到一个jQuery对象后,还可以以这个对象为基准,进行查找和过滤. 最常见的查找是在某个节点的所有子节点中查找,使用find()方法,它本身 ...

  10. No Compiler is Provided in this environment Perhaps you are running on JRE rather than a JDK

    问题描述: 在使用Jenkins打包的时候,抛出这样的错,但JDK和Maven都是已经安装,没问题了的.其中Jenkins用的Pipline流水线来部署项目. 问题解决: 在使用Pipline部署项目 ...