Skip to content

Instantly share code, notes, and snippets.

@GuyCarver
Created September 23, 2016 03:17
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save GuyCarver/d5db17c371ed24f3e8c073dc021b7853 to your computer and use it in GitHub Desktop.
Save GuyCarver/d5db17c371ed24f3e8c073dc021b7853 to your computer and use it in GitHub Desktop.
F# version of plotting.cs example for Continuous app
//
// Plotting Example
//
// Demonstrates the use of OxyPlot to plot functions.
//
open System
open System.Linq
open OxyPlot
open OxyPlot.Series
open OxyPlot.Xamarin.iOS
//
// Define some fun functions to plot
//
let SinWave = Math.Sin
let SquareWave x = float(Math.Sign(Math.Sin x))
//
// Create a plot model that holds many series
//
let plot = PlotModel()
plot.Title <- "Hello Plotting"
//
// A little function to make adding plots easier
//
let AddFunction (f : double -> float ) name =
plot.Series.Add FunctionSeries(f,-10.0,10.0,100,name)
plot.Series.Last().Background <- OxyColor.FromRgb (255uy, 250uy, 230uy)
//
// Add functions to the plot
//
AddFunction SinWave "sin"
AddFunction SquareWave "square"
//
// Display the plot
//
let Main = new PlotView()
Main.Model <- plot
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment