1951
Source/Examples/ExampleLibrary/Axes/AxisExamples.cs
Normal file
1951
Source/Examples/ExampleLibrary/Axes/AxisExamples.cs
Normal file
File diff suppressed because it is too large
Load Diff
151
Source/Examples/ExampleLibrary/Axes/CartesianAxesExamples.cs
Normal file
151
Source/Examples/ExampleLibrary/Axes/CartesianAxesExamples.cs
Normal file
@@ -0,0 +1,151 @@
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
// <copyright file="CartesianAxesExamples.cs" company="OxyPlot">
|
||||
// Copyright (c) 2014 OxyPlot contributors
|
||||
// </copyright>
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
namespace ExampleLibrary
|
||||
{
|
||||
using System;
|
||||
|
||||
using OxyPlot;
|
||||
using OxyPlot.Axes;
|
||||
using OxyPlot.Series;
|
||||
|
||||
[Examples("Cartesian axes"), Tags("Axes")]
|
||||
public class CartesianAxesExamples
|
||||
{
|
||||
[Example("Trigonometric functions")]
|
||||
public static PlotModel FunctionSeries()
|
||||
{
|
||||
var pm = new PlotModel { Title = "Trigonometric functions", PlotType = PlotType.Cartesian };
|
||||
pm.Series.Add(new FunctionSeries(Math.Sin, -10, 10, 0.1, "sin(x)"));
|
||||
pm.Series.Add(new FunctionSeries(Math.Cos, -10, 10, 0.1, "cos(x)"));
|
||||
pm.Series.Add(new FunctionSeries(t => 5 * Math.Cos(t), t => 5 * Math.Sin(t), 0, 2 * Math.PI, 1000, "cos(t),sin(t)"));
|
||||
return pm;
|
||||
}
|
||||
|
||||
[Example("Clover")]
|
||||
public static PlotModel Clover()
|
||||
{
|
||||
var plot = new PlotModel { Title = "Parametric function", PlotType = PlotType.Cartesian };
|
||||
plot.Series.Add(new FunctionSeries(t => 2 * Math.Cos(2 * t) * Math.Cos(t), t => 2 * Math.Cos(2 * t) * Math.Sin(t),
|
||||
0, Math.PI * 2, 1000, "2cos(2t)cos(t) , 2cos(2t)sin(t)"));
|
||||
return plot;
|
||||
}
|
||||
|
||||
[Example("AbsoluteMinimum Y")]
|
||||
public static PlotModel AbsoluteYmin()
|
||||
{
|
||||
var plot = new PlotModel { Title = "Y: AbsoluteMinimum = 0", PlotType = PlotType.Cartesian };
|
||||
var c = OxyColors.DarkBlue;
|
||||
plot.Axes.Add(new LinearAxis { Position = AxisPosition.Bottom, Title = "X-axis", MajorGridlineStyle = LineStyle.Solid, MinorGridlineStyle = LineStyle.Solid, MajorGridlineColor = OxyColor.FromAColor(40, c), MinorGridlineColor = OxyColor.FromAColor(20, c) });
|
||||
plot.Axes.Add(new LinearAxis { Position = AxisPosition.Left, Title = "Y-axis", AbsoluteMinimum = 0, Minimum = 0, MajorGridlineStyle = LineStyle.Solid, MinorGridlineStyle = LineStyle.Solid, MajorGridlineColor = OxyColor.FromAColor(40, c), MinorGridlineColor = OxyColor.FromAColor(20, c) });
|
||||
plot.Series.Add(CreateTestSeries());
|
||||
return plot;
|
||||
}
|
||||
|
||||
[Example("AbsoluteMinimum Y, manual plotmargins")]
|
||||
public static PlotModel AbsoluteYmin2()
|
||||
{
|
||||
var plot = new PlotModel
|
||||
{
|
||||
Title = "Y: AbsoluteMinimum = 0",
|
||||
Subtitle = "AutoAdjustPlotMargins = false",
|
||||
PlotType = PlotType.Cartesian,
|
||||
PlotMargins = new OxyThickness(60, 4, 4, 40)
|
||||
};
|
||||
var c = OxyColors.DarkBlue;
|
||||
plot.Axes.Add(new LinearAxis { Position = AxisPosition.Bottom, Title = "X-axis", MajorGridlineStyle = LineStyle.Solid, MinorGridlineStyle = LineStyle.Solid, MajorGridlineColor = OxyColor.FromAColor(40, c), MinorGridlineColor = OxyColor.FromAColor(20, c) });
|
||||
plot.Axes.Add(new LinearAxis { Position = AxisPosition.Left, Title = "Y-axis", AbsoluteMinimum = 0, Minimum = 0, MajorGridlineStyle = LineStyle.Solid, MinorGridlineStyle = LineStyle.Solid, MajorGridlineColor = OxyColor.FromAColor(40, c), MinorGridlineColor = OxyColor.FromAColor(20, c) });
|
||||
plot.Series.Add(CreateTestSeries());
|
||||
return plot;
|
||||
}
|
||||
|
||||
[Example("AbsoluteMinimum X/Y")]
|
||||
public static PlotModel AbsoluteYminXmin()
|
||||
{
|
||||
var plot = new PlotModel { Title = "X: AbsoluteMinimum = -10, Y: AbsoluteMinimum = 0", PlotType = PlotType.Cartesian };
|
||||
|
||||
var c = OxyColors.DarkBlue;
|
||||
plot.Axes.Add(new LinearAxis { Position = AxisPosition.Bottom, Title = "X-axis", AbsoluteMinimum = -10, MajorGridlineStyle = LineStyle.Solid, MinorGridlineStyle = LineStyle.Solid, MajorGridlineColor = OxyColor.FromAColor(40, c), MinorGridlineColor = OxyColor.FromAColor(20, c) });
|
||||
plot.Axes.Add(new LinearAxis { Position = AxisPosition.Left, Title = "Y-axis", AbsoluteMinimum = 0, Minimum = 0, MajorGridlineStyle = LineStyle.Solid, MinorGridlineStyle = LineStyle.Solid, MajorGridlineColor = OxyColor.FromAColor(40, c), MinorGridlineColor = OxyColor.FromAColor(20, c) });
|
||||
plot.Series.Add(CreateTestSeries());
|
||||
return plot;
|
||||
}
|
||||
|
||||
[Example("AbsoluteMinimum/Maximum Y")]
|
||||
public static PlotModel AbsoluteYminYmax()
|
||||
{
|
||||
var plot = new PlotModel { Title = "Y: AbsoluteMinimum = 0, AbsoluteMaximum = 2", PlotType = PlotType.Cartesian };
|
||||
|
||||
var c = OxyColors.DarkBlue;
|
||||
plot.Axes.Add(new LinearAxis { Position = AxisPosition.Bottom, Title = "X-axis", MajorGridlineStyle = LineStyle.Solid, MinorGridlineStyle = LineStyle.Solid, MajorGridlineColor = OxyColor.FromAColor(40, c), MinorGridlineColor = OxyColor.FromAColor(20, c) });
|
||||
plot.Axes.Add(new LinearAxis { Position = AxisPosition.Left, Title = "Y-axis", AbsoluteMinimum = 0, Minimum = 0, AbsoluteMaximum = 2, MajorGridlineStyle = LineStyle.Solid, MinorGridlineStyle = LineStyle.Solid, MajorGridlineColor = OxyColor.FromAColor(40, c), MinorGridlineColor = OxyColor.FromAColor(20, c) });
|
||||
plot.Series.Add(CreateTestSeries());
|
||||
return plot;
|
||||
}
|
||||
|
||||
[Example("AbsoluteMinimum Y, AbsoluteMinimum/Maximum X")]
|
||||
public static PlotModel AbsoluteYminXminXmax()
|
||||
{
|
||||
var plot = new PlotModel { Title = "Y: AbsoluteMinimum = 0, X: AbsoluteMinimum = -10, AbsoluteMaximum = 10", PlotType = PlotType.Cartesian };
|
||||
|
||||
var c = OxyColors.DarkBlue;
|
||||
plot.Axes.Add(new LinearAxis { Position = AxisPosition.Bottom, Title = "X-axis", AbsoluteMinimum = -10, AbsoluteMaximum = 10, MajorGridlineStyle = LineStyle.Solid, MinorGridlineStyle = LineStyle.Solid, MajorGridlineColor = OxyColor.FromAColor(40, c), MinorGridlineColor = OxyColor.FromAColor(20, c) });
|
||||
plot.Axes.Add(new LinearAxis { Position = AxisPosition.Left, Title = "Y-axis", AbsoluteMinimum = 0, Minimum = 0, MajorGridlineStyle = LineStyle.Solid, MinorGridlineStyle = LineStyle.Solid, MajorGridlineColor = OxyColor.FromAColor(40, c), MinorGridlineColor = OxyColor.FromAColor(20, c) });
|
||||
plot.Series.Add(CreateTestSeries());
|
||||
|
||||
return plot;
|
||||
}
|
||||
|
||||
[Example("AbsoluteMinimum/Maximum X/Y")]
|
||||
public static PlotModel AbsoluteYminYmaxXminXmax()
|
||||
{
|
||||
var plot = new PlotModel { Title = "Y: AbsoluteMinimum = 0, AbsoluteMaximum = 2, X: AbsoluteMinimum = -10, AbsoluteMaximum = 10", PlotType = PlotType.Cartesian };
|
||||
|
||||
var c = OxyColors.DarkBlue;
|
||||
plot.Axes.Add(new LinearAxis { Position = AxisPosition.Bottom, Title = "X-axis", AbsoluteMinimum = -10, AbsoluteMaximum = 10, MajorGridlineStyle = LineStyle.Solid, MinorGridlineStyle = LineStyle.Solid, MajorGridlineColor = OxyColor.FromAColor(40, c), MinorGridlineColor = OxyColor.FromAColor(20, c) });
|
||||
plot.Axes.Add(new LinearAxis { Position = AxisPosition.Left, Title = "Y-axis", AbsoluteMinimum = 0, Minimum = 0, AbsoluteMaximum = 2, MajorGridlineStyle = LineStyle.Solid, MinorGridlineStyle = LineStyle.Solid, MajorGridlineColor = OxyColor.FromAColor(40, c), MinorGridlineColor = OxyColor.FromAColor(20, c) });
|
||||
plot.Series.Add(CreateTestSeries());
|
||||
|
||||
return plot;
|
||||
}
|
||||
|
||||
private static OxyPlot.Series.Series CreateTestSeries()
|
||||
{
|
||||
var absSerie = new LineSeries();
|
||||
|
||||
absSerie.Points.Add(new DataPoint(-8.0, 0.0));
|
||||
absSerie.Points.Add(new DataPoint(-7.5, 0.1));
|
||||
absSerie.Points.Add(new DataPoint(-7.0, 0.2));
|
||||
absSerie.Points.Add(new DataPoint(-6.0, 0.4));
|
||||
absSerie.Points.Add(new DataPoint(-5.0, 0.5));
|
||||
absSerie.Points.Add(new DataPoint(-4.0, 0.6));
|
||||
absSerie.Points.Add(new DataPoint(-3.0, 0.7));
|
||||
absSerie.Points.Add(new DataPoint(-2.0, 0.8));
|
||||
absSerie.Points.Add(new DataPoint(-1.0, 0.9));
|
||||
absSerie.Points.Add(new DataPoint(0.0, 1.0));
|
||||
absSerie.Points.Add(new DataPoint(1.0, 0.9));
|
||||
absSerie.Points.Add(new DataPoint(2.0, 0.8));
|
||||
absSerie.Points.Add(new DataPoint(3.0, 0.7));
|
||||
absSerie.Points.Add(new DataPoint(4.0, 0.6));
|
||||
absSerie.Points.Add(new DataPoint(5.0, 0.5));
|
||||
absSerie.Points.Add(new DataPoint(6.0, 0.4));
|
||||
absSerie.Points.Add(new DataPoint(7.0, 0.2));
|
||||
absSerie.Points.Add(new DataPoint(7.5, 0.1));
|
||||
absSerie.Points.Add(new DataPoint(8.0, 0.0));
|
||||
|
||||
absSerie.Points.Add(DataPoint.Undefined);
|
||||
|
||||
// Plot a square
|
||||
absSerie.Points.Add(new DataPoint(-0.5, 0.5));
|
||||
absSerie.Points.Add(new DataPoint(-0.5, 1.5));
|
||||
absSerie.Points.Add(new DataPoint(0.5, 1.5));
|
||||
absSerie.Points.Add(new DataPoint(0.5, 0.5));
|
||||
absSerie.Points.Add(new DataPoint(-0.5, 0.5));
|
||||
|
||||
return absSerie;
|
||||
}
|
||||
}
|
||||
}
|
||||
79
Source/Examples/ExampleLibrary/Axes/CategoryAxisExamples.cs
Normal file
79
Source/Examples/ExampleLibrary/Axes/CategoryAxisExamples.cs
Normal file
@@ -0,0 +1,79 @@
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
// <copyright file="CategoryAxisExamples.cs" company="OxyPlot">
|
||||
// Copyright (c) 2014 OxyPlot contributors
|
||||
// </copyright>
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
namespace ExampleLibrary
|
||||
{
|
||||
using OxyPlot;
|
||||
using OxyPlot.Axes;
|
||||
|
||||
[Examples("CategoryAxis"), Tags("Axes")]
|
||||
public static class CategoryAxisExamples
|
||||
{
|
||||
[Example("Standard")]
|
||||
public static PlotModel StandardCategoryAxis()
|
||||
{
|
||||
var plotModel1 = new PlotModel { Title = "Standard" };
|
||||
var catAxis = new CategoryAxis();
|
||||
catAxis.Labels.AddRange(new[] { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12" });
|
||||
plotModel1.Axes.Add(catAxis);
|
||||
var linearAxis = new LinearAxis { Position = AxisPosition.Left };
|
||||
plotModel1.Axes.Add(linearAxis);
|
||||
return plotModel1;
|
||||
}
|
||||
|
||||
[Example("ItemsSource - string[]")]
|
||||
public static PlotModel ItemsSourceStrings()
|
||||
{
|
||||
var model = new PlotModel { Title = "CategoryAxis with string[] as ItemsSource" };
|
||||
model.Axes.Add(new CategoryAxis
|
||||
{
|
||||
StringFormat = "Item {0}",
|
||||
ItemsSource = new[] { "A", "B", "C" }
|
||||
});
|
||||
var linearAxis = new LinearAxis { Position = AxisPosition.Left };
|
||||
model.Axes.Add(linearAxis);
|
||||
return model;
|
||||
}
|
||||
|
||||
[Example("ItemsSource - int[]")]
|
||||
public static PlotModel ItemsSourceValues()
|
||||
{
|
||||
var model = new PlotModel { Title = "CategoryAxis with int[] as ItemsSource" };
|
||||
model.Axes.Add(new CategoryAxis
|
||||
{
|
||||
StringFormat = "Item {0}",
|
||||
ItemsSource = new[] { 10, 100, 123 }
|
||||
});
|
||||
var linearAxis = new LinearAxis { Position = AxisPosition.Left };
|
||||
model.Axes.Add(linearAxis);
|
||||
return model;
|
||||
}
|
||||
|
||||
[Example("MajorStep")]
|
||||
public static PlotModel MajorStepCategoryAxis()
|
||||
{
|
||||
var plotModel1 = new PlotModel { Title = "Major Step = 4, IsTickCentered = false" };
|
||||
var catAxis = new CategoryAxis { IsTickCentered = false, MajorStep = 4 };
|
||||
catAxis.Labels.AddRange(new[] { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12" });
|
||||
plotModel1.Axes.Add(catAxis);
|
||||
var linearAxis = new LinearAxis { Position = AxisPosition.Left };
|
||||
plotModel1.Axes.Add(linearAxis);
|
||||
return plotModel1;
|
||||
}
|
||||
|
||||
[Example("MajorStep, TickCentered")]
|
||||
public static PlotModel MajorStepCategoryTickCenteredAxis()
|
||||
{
|
||||
var plotModel1 = new PlotModel { Title = "Major Step = 4, IsTickCentered = true" };
|
||||
var catAxis = new CategoryAxis { IsTickCentered = true, MajorStep = 4 };
|
||||
catAxis.Labels.AddRange(new[] { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12" });
|
||||
plotModel1.Axes.Add(catAxis);
|
||||
var linearAxis = new LinearAxis { Position = AxisPosition.Left };
|
||||
plotModel1.Axes.Add(linearAxis);
|
||||
return plotModel1;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
// <copyright file="CategoryColorAxisExamples.cs" company="OxyPlot">
|
||||
// Copyright (c) 2014 OxyPlot contributors
|
||||
// </copyright>
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
namespace ExampleLibrary
|
||||
{
|
||||
using OxyPlot;
|
||||
using OxyPlot.Axes;
|
||||
using OxyPlot.Series;
|
||||
|
||||
[Examples("CategoryColorAxis"), Tags("Axes")]
|
||||
public class CategoryColorAxisExamples
|
||||
{
|
||||
[Example("CategoryColorAxis")]
|
||||
public static PlotModel StandardCategoryColorAxis()
|
||||
{
|
||||
var plotModel1 = new PlotModel { Title = "CategoryColorAxis" };
|
||||
var catAxis = new CategoryColorAxis { Key = "ccc", Palette = OxyPalettes.BlackWhiteRed(12) };
|
||||
catAxis.Labels.AddRange(new[] { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12" });
|
||||
plotModel1.Axes.Add(catAxis);
|
||||
var linearAxis = new LinearAxis { Position = AxisPosition.Left };
|
||||
var ss = new ScatterSeries { ColorAxisKey = catAxis.Key };
|
||||
ss.Points.Add(new ScatterPoint(0, 0) { Value = 0 });
|
||||
ss.Points.Add(new ScatterPoint(3, 0) { Value = 3 });
|
||||
plotModel1.Series.Add(ss);
|
||||
plotModel1.Axes.Add(linearAxis);
|
||||
return plotModel1;
|
||||
}
|
||||
|
||||
[Example("Centered ticks, MajorStep = 4")]
|
||||
public static PlotModel MajorStep4()
|
||||
{
|
||||
var plotModel1 = new PlotModel { Title = "Major Step = 4, IsTickCentered = true" };
|
||||
var catAxis = new CategoryColorAxis
|
||||
{
|
||||
Palette = OxyPalettes.BlackWhiteRed(3),
|
||||
IsTickCentered = true,
|
||||
MajorStep = 4
|
||||
};
|
||||
catAxis.Labels.AddRange(new[] { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12" });
|
||||
plotModel1.Axes.Add(catAxis);
|
||||
var linearAxis = new LinearAxis { Position = AxisPosition.Left };
|
||||
plotModel1.Axes.Add(linearAxis);
|
||||
return plotModel1;
|
||||
}
|
||||
}
|
||||
}
|
||||
53
Source/Examples/ExampleLibrary/Axes/CustomAxisExamples.cs
Normal file
53
Source/Examples/ExampleLibrary/Axes/CustomAxisExamples.cs
Normal file
@@ -0,0 +1,53 @@
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
// <copyright file="CustomAxisExamples.cs" company="OxyPlot">
|
||||
// Copyright (c) 2014 OxyPlot contributors
|
||||
// </copyright>
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
namespace ExampleLibrary
|
||||
{
|
||||
using System.Collections.Generic;
|
||||
|
||||
using OxyPlot;
|
||||
using OxyPlot.Axes;
|
||||
|
||||
[Examples("Custom axes"), Tags("Axes")]
|
||||
public static class CustomAxisExamples
|
||||
{
|
||||
public class ArrowAxis : LinearAxis
|
||||
{
|
||||
public override void Render(IRenderContext rc, int pass)
|
||||
{
|
||||
base.Render(rc, pass);
|
||||
var points = new List<ScreenPoint>();
|
||||
if (this.IsHorizontal())
|
||||
{
|
||||
var xmax = this.Transform(this.ActualMaximum);
|
||||
points.Add(new ScreenPoint(xmax + 4, this.PlotModel.PlotArea.Bottom - 4));
|
||||
points.Add(new ScreenPoint(xmax + 18, this.PlotModel.PlotArea.Bottom));
|
||||
points.Add(new ScreenPoint(xmax + 4, this.PlotModel.PlotArea.Bottom + 4));
|
||||
//// etc.
|
||||
}
|
||||
else
|
||||
{
|
||||
var ymax = this.Transform(this.ActualMaximum);
|
||||
points.Add(new ScreenPoint(this.PlotModel.PlotArea.Left - 4, ymax - 4));
|
||||
points.Add(new ScreenPoint(this.PlotModel.PlotArea.Left, ymax - 18));
|
||||
points.Add(new ScreenPoint(this.PlotModel.PlotArea.Left + 4, ymax - 4));
|
||||
//// etc.
|
||||
}
|
||||
|
||||
rc.DrawPolygon(points, OxyColors.Black, OxyColors.Undefined, 0, this.EdgeRenderingMode);
|
||||
}
|
||||
}
|
||||
|
||||
[Example("ArrowAxis")]
|
||||
public static PlotModel CustomArrowAxis()
|
||||
{
|
||||
var model = new PlotModel { PlotAreaBorderThickness = new OxyThickness(0), PlotMargins = new OxyThickness(60, 60, 60, 60) };
|
||||
model.Axes.Add(new ArrowAxis { Position = AxisPosition.Bottom, AxislineStyle = LineStyle.Solid });
|
||||
model.Axes.Add(new ArrowAxis { Position = AxisPosition.Left, AxislineStyle = LineStyle.Solid });
|
||||
return model;
|
||||
}
|
||||
}
|
||||
}
|
||||
248
Source/Examples/ExampleLibrary/Axes/DateTimeAxisExamples.cs
Normal file
248
Source/Examples/ExampleLibrary/Axes/DateTimeAxisExamples.cs
Normal file
@@ -0,0 +1,248 @@
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
// <copyright file="DateTimeAxisExamples.cs" company="OxyPlot">
|
||||
// Copyright (c) 2014 OxyPlot contributors
|
||||
// </copyright>
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
namespace ExampleLibrary
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Globalization;
|
||||
|
||||
using OxyPlot;
|
||||
using OxyPlot.Axes;
|
||||
using OxyPlot.Series;
|
||||
|
||||
[Examples("DateTimeAxis"), Tags("Axes")]
|
||||
public static class DateTimeAxisExamples
|
||||
{
|
||||
public class DateValue
|
||||
{
|
||||
public DateTime Date { get; set; }
|
||||
public double Value { get; set; }
|
||||
}
|
||||
|
||||
[Example("Default StringFormat")]
|
||||
public static PlotModel DefaultValues()
|
||||
{
|
||||
return CreateExample(7, null);
|
||||
}
|
||||
|
||||
[Example("StringFormat 'MMM dd\\nyyyy'")]
|
||||
public static PlotModel StringFormat()
|
||||
{
|
||||
return CreateExample(7, "MMM dd\nyyyy");
|
||||
}
|
||||
|
||||
private static PlotModel CreateExample(int days, string stringFormat)
|
||||
{
|
||||
var m = new PlotModel();
|
||||
var startTime = new DateTime(2000, 1, 1);
|
||||
var min = DateTimeAxis.ToDouble(startTime);
|
||||
var max = min + days;
|
||||
m.Axes.Add(new DateTimeAxis { Position = AxisPosition.Bottom, Minimum = min, Maximum = max, StringFormat = stringFormat });
|
||||
m.Axes.Add(new DateTimeAxis { Position = AxisPosition.Left, Minimum = min, Maximum = max, StringFormat = stringFormat });
|
||||
return m;
|
||||
}
|
||||
|
||||
// [Example("DateTime Minimum bug")]
|
||||
public static PlotModel Example1()
|
||||
{
|
||||
var tmp = new PlotModel { Title = "Test" };
|
||||
tmp.Axes.Add(new LinearAxis { Position = AxisPosition.Left, MajorGridlineStyle = LineStyle.Solid, MinorGridlineStyle = LineStyle.Dot, TickStyle = TickStyle.Outside });
|
||||
var dt = new DateTime(2010, 1, 1);
|
||||
tmp.Axes.Add(new DateTimeAxis
|
||||
{
|
||||
Position = AxisPosition.Bottom,
|
||||
Minimum = DateTimeAxis.ToDouble(dt),
|
||||
Maximum = DateTimeAxis.ToDouble(dt.AddDays(1)),
|
||||
IntervalType = DateTimeIntervalType.Hours,
|
||||
MajorGridlineStyle = LineStyle.Solid,
|
||||
Angle = 90,
|
||||
StringFormat = "HH:mm",
|
||||
MajorStep = 1.0 / 24 / 2, // 1/24 = 1 hour, 1/24/2 = 30 minutes
|
||||
IsZoomEnabled = true,
|
||||
MaximumPadding = 0,
|
||||
MinimumPadding = 0,
|
||||
TickStyle = TickStyle.None
|
||||
});
|
||||
|
||||
var ls = new LineSeries { Title = "Line1", DataFieldX = "X", DataFieldY = "Y" };
|
||||
var ii = new List<Item>();
|
||||
|
||||
for (int i = 0; i < 24; i++)
|
||||
ii.Add(new Item { X = dt.AddHours(i), Y = i * i });
|
||||
ls.ItemsSource = ii;
|
||||
tmp.Series.Add(ls);
|
||||
return tmp;
|
||||
}
|
||||
|
||||
[Example("TimeZone adjustments")]
|
||||
public static PlotModel DaylightSavingsBreak()
|
||||
{
|
||||
var m = new PlotModel();
|
||||
|
||||
var xa = new DateTimeAxis { Position = AxisPosition.Bottom };
|
||||
// TimeZone not available in PCL...
|
||||
|
||||
m.Axes.Add(xa);
|
||||
m.Axes.Add(new LinearAxis { Position = AxisPosition.Left });
|
||||
var ls = new LineSeries { MarkerType = MarkerType.Circle };
|
||||
m.Series.Add(ls);
|
||||
|
||||
// set the origin of the curve to 2013-03-31 00:00:00 (UTC)
|
||||
var o = new DateTime(2013, 3, 31, 0, 0, 0, DateTimeKind.Utc);
|
||||
|
||||
// add points at 10min intervals
|
||||
// at 2am the clocks are turned forward 1 hour (W. Europe Standard Time)
|
||||
for (int i = 0; i < 400; i += 10)
|
||||
{
|
||||
var time = o.AddMinutes(i);
|
||||
ls.Points.Add(DateTimeAxis.CreateDataPoint(time, i));
|
||||
}
|
||||
|
||||
return m;
|
||||
}
|
||||
|
||||
public class Item
|
||||
{
|
||||
public DateTime X { get; set; }
|
||||
public double Y { get; set; }
|
||||
}
|
||||
|
||||
[Example("DateTime axis")]
|
||||
public static PlotModel DateTimeaxisPlotModel()
|
||||
{
|
||||
var start = new DateTime(2010, 01, 01);
|
||||
var end = new DateTime(2015, 01, 01);
|
||||
double increment = 3600 * 24 * 14;
|
||||
|
||||
// Create a random data collection
|
||||
var r = new Random(13);
|
||||
var data = new Collection<DateValue>();
|
||||
var date = start;
|
||||
while (date <= end)
|
||||
{
|
||||
data.Add(new DateValue { Date = date, Value = r.NextDouble() });
|
||||
date = date.AddSeconds(increment);
|
||||
}
|
||||
|
||||
var plotModel1 = new PlotModel { Title = "DateTime axis" };
|
||||
var dateTimeAxis1 = new DateTimeAxis
|
||||
{
|
||||
CalendarWeekRule = CalendarWeekRule.FirstFourDayWeek,
|
||||
FirstDayOfWeek = DayOfWeek.Monday,
|
||||
Position = AxisPosition.Bottom
|
||||
};
|
||||
plotModel1.Axes.Add(dateTimeAxis1);
|
||||
var linearAxis1 = new LinearAxis();
|
||||
plotModel1.Axes.Add(linearAxis1);
|
||||
var lineSeries1 = new LineSeries
|
||||
{
|
||||
Color = OxyColor.FromArgb(255, 78, 154, 6),
|
||||
MarkerFill = OxyColor.FromArgb(255, 78, 154, 6),
|
||||
MarkerStroke = OxyColors.ForestGreen,
|
||||
MarkerType = MarkerType.Plus,
|
||||
StrokeThickness = 1,
|
||||
DataFieldX = "Date",
|
||||
DataFieldY = "Value",
|
||||
ItemsSource = data
|
||||
};
|
||||
plotModel1.Series.Add(lineSeries1);
|
||||
return plotModel1;
|
||||
}
|
||||
|
||||
public class SunItem
|
||||
{
|
||||
public DateTime Day { get; set; }
|
||||
public TimeSpan Sunrise { get; set; }
|
||||
public TimeSpan Sunset { get; set; }
|
||||
}
|
||||
|
||||
private static Collection<SunItem> CreateSunData(int year, double lat, double lon, Func<DateTime, DateTime> utcToLocalTime)
|
||||
{
|
||||
var data = new Collection<SunItem>();
|
||||
var day = new DateTime(year, 1, 1);
|
||||
|
||||
while (day.Year == year)
|
||||
{
|
||||
var sunrise = Sun.Calculate(day, lat, lon, true, utcToLocalTime);
|
||||
var sunset = Sun.Calculate(day, lat, lon, false, utcToLocalTime);
|
||||
data.Add(new SunItem { Day = day, Sunrise = sunrise - day, Sunset = sunset - day });
|
||||
day = day.AddDays(1);
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
public static bool IsDaylightSaving(DateTime time)
|
||||
{
|
||||
// Daylight saving starts last sunday in March and ends last sunday in October
|
||||
// http://en.wikipedia.org/wiki/Daylight_saving_time
|
||||
var start = new DateTime(time.Year, 3, 31, 2, 0, 0);
|
||||
start = start.AddDays(-(int)start.DayOfWeek);
|
||||
var end = new DateTime(time.Year, 10, 31, 3, 0, 0);
|
||||
end = end.AddDays(-(int)end.DayOfWeek);
|
||||
return time >= start && time <= end;
|
||||
}
|
||||
|
||||
[Example("Sunrise and sunset in Oslo")]
|
||||
public static PlotModel SunriseandsunsetinOslo()
|
||||
{
|
||||
int year = DateTime.Now.Year;
|
||||
|
||||
// Convert UTC time to Western European Time (WET)
|
||||
Func<DateTime, DateTime> utcToLocalTime = utc => utc.AddHours(IsDaylightSaving(utc) ? 2 : 1);
|
||||
|
||||
var sunData = CreateSunData(year, 59.91, 10.75, utcToLocalTime);
|
||||
|
||||
var plotModel1 = new PlotModel { Title = "Sunrise and sunset in Oslo", Subtitle = "UTC time" };
|
||||
|
||||
var dateTimeAxis1 = new DateTimeAxis
|
||||
{
|
||||
CalendarWeekRule = CalendarWeekRule.FirstFourDayWeek,
|
||||
FirstDayOfWeek = DayOfWeek.Monday,
|
||||
IntervalType = DateTimeIntervalType.Months,
|
||||
MajorGridlineStyle = LineStyle.Solid,
|
||||
Position = AxisPosition.Bottom,
|
||||
StringFormat = "MMM"
|
||||
};
|
||||
plotModel1.Axes.Add(dateTimeAxis1);
|
||||
var timeSpanAxis1 = new TimeSpanAxis { MajorGridlineStyle = LineStyle.Solid, Maximum = 86400, Minimum = 0, StringFormat = "h:mm" };
|
||||
plotModel1.Axes.Add(timeSpanAxis1);
|
||||
var areaSeries1 = new AreaSeries
|
||||
{
|
||||
ItemsSource = sunData,
|
||||
DataFieldX = "Day",
|
||||
DataFieldY = "Sunrise",
|
||||
DataFieldX2 = "Day",
|
||||
DataFieldY2 = "Sunset",
|
||||
Fill = OxyColor.FromArgb(128, 255, 255, 0),
|
||||
Color = OxyColors.Black
|
||||
};
|
||||
plotModel1.Series.Add(areaSeries1);
|
||||
return plotModel1;
|
||||
}
|
||||
|
||||
[Example("LabelFormatter")]
|
||||
public static PlotModel LabelFormatter()
|
||||
{
|
||||
var model = new PlotModel { Title = "Using LabelFormatter to format labels by day of week" };
|
||||
model.Axes.Add(new DateTimeAxis { LabelFormatter = x => DateTimeAxis.ToDateTime(x).DayOfWeek.ToString().Substring(0, 3) });
|
||||
var series = new LineSeries();
|
||||
model.Series.Add(series);
|
||||
for (int i = 0; i < 7; i++)
|
||||
{
|
||||
var time = new DateTime(2014, 9, 10).AddDays(i);
|
||||
double x = DateTimeAxis.ToDouble(time);
|
||||
double y = Math.Sin(i * i);
|
||||
series.Points.Add(new DataPoint(x, y));
|
||||
}
|
||||
|
||||
return model;
|
||||
}
|
||||
}
|
||||
}
|
||||
141
Source/Examples/ExampleLibrary/Axes/LinearAxisExamples.cs
Normal file
141
Source/Examples/ExampleLibrary/Axes/LinearAxisExamples.cs
Normal file
@@ -0,0 +1,141 @@
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
// <copyright file="LinearAxisExamples.cs" company="OxyPlot">
|
||||
// Copyright (c) 2014 OxyPlot contributors
|
||||
// </copyright>
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
namespace ExampleLibrary
|
||||
{
|
||||
using OxyPlot;
|
||||
using OxyPlot.Axes;
|
||||
|
||||
[Examples("LinearAxis"), Tags("Axes")]
|
||||
public static class LinearAxisExamples
|
||||
{
|
||||
[Example("Default StringFormat ('g6')")]
|
||||
public static PlotModel StringFormat()
|
||||
{
|
||||
return CreateExample(1.2345678901234567890e5, 1.2345678901234567890e6, null);
|
||||
}
|
||||
|
||||
[Example("StringFormat = 'g2'")]
|
||||
public static PlotModel StringFormatG2()
|
||||
{
|
||||
return CreateExample(1.2345678901234567890e5, 1.2345678901234567890e6, "g2");
|
||||
}
|
||||
|
||||
[Example("StringFormat = 'g10'")]
|
||||
public static PlotModel StringFormatG10()
|
||||
{
|
||||
return CreateExample(1.2345678901234567890e5, 1.2345678901234567890e6, "g10");
|
||||
}
|
||||
|
||||
[Example("StringFormat = 'f2'")]
|
||||
public static PlotModel StringFormatF2()
|
||||
{
|
||||
return CreateExample(1.2345678901234567890e5, 1.2345678901234567890e6, "f2");
|
||||
}
|
||||
|
||||
private static PlotModel CreateExample(double min, double max, string stringFormat)
|
||||
{
|
||||
var m = new PlotModel();
|
||||
m.Axes.Add(new LinearAxis { Position = AxisPosition.Bottom, Minimum = min, Maximum = max, StringFormat = stringFormat });
|
||||
m.Axes.Add(new LinearAxis { Position = AxisPosition.Left, Minimum = min, Maximum = max, StringFormat = stringFormat });
|
||||
return m;
|
||||
}
|
||||
|
||||
[Example("TickStyle: None")]
|
||||
public static PlotModel TickStyleNone()
|
||||
{
|
||||
return CreateTickStyleModel(TickStyle.None);
|
||||
}
|
||||
|
||||
[Example("TickStyle: Crossing")]
|
||||
public static PlotModel TickStyleCrossing()
|
||||
{
|
||||
return CreateTickStyleModel(TickStyle.Crossing);
|
||||
}
|
||||
|
||||
[Example("TickStyle: Inside")]
|
||||
public static PlotModel TickStyleInside()
|
||||
{
|
||||
return CreateTickStyleModel(TickStyle.Inside);
|
||||
}
|
||||
|
||||
[Example("TickStyle: Outside")]
|
||||
public static PlotModel TickStyleOutside()
|
||||
{
|
||||
return CreateTickStyleModel(TickStyle.Outside);
|
||||
}
|
||||
|
||||
private static PlotModel CreateTickStyleModel(TickStyle tickStyle)
|
||||
{
|
||||
var model = new PlotModel { Title = "TickStyle: " + tickStyle };
|
||||
model.Axes.Add(new LinearAxis
|
||||
{
|
||||
Position = AxisPosition.Bottom,
|
||||
TickStyle = tickStyle,
|
||||
MajorGridlineStyle = LineStyle.None,
|
||||
MinorGridlineStyle = LineStyle.None,
|
||||
MaximumPadding = 0,
|
||||
MinimumPadding = 0
|
||||
});
|
||||
model.Axes.Add(new LinearAxis
|
||||
{
|
||||
Position = AxisPosition.Left,
|
||||
TickStyle = tickStyle,
|
||||
MajorGridlineStyle = LineStyle.None,
|
||||
MinorGridlineStyle = LineStyle.None,
|
||||
MaximumPadding = 0,
|
||||
MinimumPadding = 0
|
||||
});
|
||||
return model;
|
||||
}
|
||||
|
||||
[Example("Gridlines: None")]
|
||||
public static PlotModel GridlinesNone()
|
||||
{
|
||||
return CreateGridlinesModel("None", LineStyle.None, LineStyle.None);
|
||||
}
|
||||
|
||||
[Example("Gridlines: Horizontal")]
|
||||
public static PlotModel GridlinesHorizontal()
|
||||
{
|
||||
return CreateGridlinesModel("Horizontal", LineStyle.Solid, LineStyle.None);
|
||||
}
|
||||
|
||||
[Example("Gridlines: Vertical")]
|
||||
public static PlotModel GridlinesVertical()
|
||||
{
|
||||
return CreateGridlinesModel("Vertical", LineStyle.None, LineStyle.Solid);
|
||||
}
|
||||
|
||||
[Example("Gridlines: Both")]
|
||||
public static PlotModel GridlinesBoth()
|
||||
{
|
||||
return CreateGridlinesModel("Both", LineStyle.Solid, LineStyle.Solid);
|
||||
}
|
||||
|
||||
private static PlotModel CreateGridlinesModel(string title, LineStyle horizontal, LineStyle vertical)
|
||||
{
|
||||
var model = new PlotModel { Title = "Gridlines: " + title };
|
||||
model.Axes.Add(new LinearAxis
|
||||
{
|
||||
Position = AxisPosition.Bottom,
|
||||
MajorGridlineStyle = vertical,
|
||||
MinorGridlineStyle = vertical == LineStyle.Solid ? LineStyle.Dot : LineStyle.None,
|
||||
MaximumPadding = 0,
|
||||
MinimumPadding = 0
|
||||
});
|
||||
model.Axes.Add(new LinearAxis
|
||||
{
|
||||
Position = AxisPosition.Left,
|
||||
MajorGridlineStyle = horizontal,
|
||||
MinorGridlineStyle = horizontal == LineStyle.Solid ? LineStyle.Dot : LineStyle.None,
|
||||
MaximumPadding = 0,
|
||||
MinimumPadding = 0
|
||||
});
|
||||
return model;
|
||||
}
|
||||
}
|
||||
}
|
||||
247
Source/Examples/ExampleLibrary/Axes/LinearColorAxisExamples.cs
Normal file
247
Source/Examples/ExampleLibrary/Axes/LinearColorAxisExamples.cs
Normal file
@@ -0,0 +1,247 @@
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
// <copyright file="LinearColorAxisExamples.cs" company="OxyPlot">
|
||||
// Copyright (c) 2014 OxyPlot contributors
|
||||
// </copyright>
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
namespace ExampleLibrary
|
||||
{
|
||||
using OxyPlot;
|
||||
using OxyPlot.Axes;
|
||||
|
||||
[Examples("LinearColorAxis"), Tags("Axes")]
|
||||
public class LinearColorAxisExamples
|
||||
{
|
||||
[Example("Default palette")]
|
||||
public static PlotModel DefaultPalette()
|
||||
{
|
||||
var model = HeatMapSeriesExamples.CreatePeaks(null, false);
|
||||
model.Axes.Clear();
|
||||
model.Axes.Add(new LinearColorAxis { Position = AxisPosition.Right });
|
||||
return model;
|
||||
}
|
||||
|
||||
[Example("Jet (200 colors) palette")]
|
||||
public static PlotModel Jet200()
|
||||
{
|
||||
return HeatMapSeriesExamples.CreatePeaks(OxyPalettes.Jet(200), false);
|
||||
}
|
||||
|
||||
[Example("Jet (20 colors) palette")]
|
||||
public static PlotModel Jet20()
|
||||
{
|
||||
return HeatMapSeriesExamples.CreatePeaks(OxyPalettes.Jet(20), false);
|
||||
}
|
||||
|
||||
[Example("Hue (400 colors) palette")]
|
||||
public static PlotModel Hue400()
|
||||
{
|
||||
return HeatMapSeriesExamples.CreatePeaks(OxyPalettes.Hue(400), false);
|
||||
}
|
||||
|
||||
[Example("Hue distinct (200 colors) palette")]
|
||||
public static PlotModel HueDistinct200()
|
||||
{
|
||||
return HeatMapSeriesExamples.CreatePeaks(OxyPalettes.HueDistinct(200), false);
|
||||
}
|
||||
|
||||
[Example("Hue distinct reversed (200 colors) palette")]
|
||||
public static PlotModel HueDistinctReverse200()
|
||||
{
|
||||
return HeatMapSeriesExamples.CreatePeaks(OxyPalettes.HueDistinct(200).Reverse(), false);
|
||||
}
|
||||
|
||||
[Example("Hot (200 colors) palette")]
|
||||
public static PlotModel Hot200()
|
||||
{
|
||||
return HeatMapSeriesExamples.CreatePeaks(OxyPalettes.Hot(200), false);
|
||||
}
|
||||
|
||||
[Example("Hot (64 colors) palette")]
|
||||
public static PlotModel Hot64()
|
||||
{
|
||||
return HeatMapSeriesExamples.CreatePeaks(OxyPalettes.Hot64, false);
|
||||
}
|
||||
|
||||
[Example("Hot (30 colors) palette")]
|
||||
public static PlotModel Hot30()
|
||||
{
|
||||
return HeatMapSeriesExamples.CreatePeaks(OxyPalettes.Hot(30), false);
|
||||
}
|
||||
|
||||
[Example("Blue-white-red (200 colors) palette")]
|
||||
public static PlotModel BlueWhiteRed200()
|
||||
{
|
||||
return HeatMapSeriesExamples.CreatePeaks(OxyPalettes.BlueWhiteRed(200), false);
|
||||
}
|
||||
|
||||
[Example("Blue-white-red (40 colors) palette")]
|
||||
public static PlotModel BlueWhiteRed40()
|
||||
{
|
||||
return HeatMapSeriesExamples.CreatePeaks(OxyPalettes.BlueWhiteRed(40), false);
|
||||
}
|
||||
|
||||
[Example("Black-white-red (500 colors) palette")]
|
||||
public static PlotModel BlackWhiteRed500()
|
||||
{
|
||||
return HeatMapSeriesExamples.CreatePeaks(OxyPalettes.BlackWhiteRed(500), false);
|
||||
}
|
||||
|
||||
[Example("Black-white-red (3 colors) palette")]
|
||||
public static PlotModel BlackWhiteRed3()
|
||||
{
|
||||
return HeatMapSeriesExamples.CreatePeaks(OxyPalettes.BlackWhiteRed(3), false);
|
||||
}
|
||||
|
||||
[Example("Cool (200 colors) palette")]
|
||||
public static PlotModel Cool200()
|
||||
{
|
||||
return HeatMapSeriesExamples.CreatePeaks(OxyPalettes.Cool(200), false);
|
||||
}
|
||||
|
||||
[Example("Rainbow (200 colors) palette")]
|
||||
public static PlotModel Rainbow200()
|
||||
{
|
||||
return HeatMapSeriesExamples.CreatePeaks(OxyPalettes.Rainbow(200), false);
|
||||
}
|
||||
|
||||
[Example("Viridis palette")]
|
||||
public static PlotModel Viridis()
|
||||
{
|
||||
return HeatMapSeriesExamples.CreatePeaks(OxyPalettes.Viridis(), false);
|
||||
}
|
||||
|
||||
[Example("Plasma palette")]
|
||||
public static PlotModel Plasma()
|
||||
{
|
||||
return HeatMapSeriesExamples.CreatePeaks(OxyPalettes.Plasma(), false);
|
||||
}
|
||||
|
||||
[Example("Magma palette")]
|
||||
public static PlotModel Magma()
|
||||
{
|
||||
return HeatMapSeriesExamples.CreatePeaks(OxyPalettes.Magma(), false);
|
||||
}
|
||||
|
||||
[Example("Inferno palette")]
|
||||
public static PlotModel Inferno()
|
||||
{
|
||||
return HeatMapSeriesExamples.CreatePeaks(OxyPalettes.Inferno(), false);
|
||||
}
|
||||
|
||||
[Example("Cividis palette")]
|
||||
public static PlotModel Cividis()
|
||||
{
|
||||
return HeatMapSeriesExamples.CreatePeaks(OxyPalettes.Cividis(), false);
|
||||
}
|
||||
|
||||
[Example("Viridis (10 colors) palette")]
|
||||
public static PlotModel Viridis10()
|
||||
{
|
||||
return HeatMapSeriesExamples.CreatePeaks(OxyPalettes.Viridis(10), false);
|
||||
}
|
||||
|
||||
[Example("Rainbow (7 colors) palette")]
|
||||
public static PlotModel Rainbow7()
|
||||
{
|
||||
return HeatMapSeriesExamples.CreatePeaks(OxyPalettes.Rainbow(7), false);
|
||||
}
|
||||
|
||||
[Example("Vertical (6 colors)")]
|
||||
public static PlotModel Vertical_6()
|
||||
{
|
||||
return HeatMapSeriesExamples.CreatePeaks(OxyPalettes.Jet(6), false);
|
||||
}
|
||||
|
||||
[Example("Vertical reverse (6 colors)")]
|
||||
public static PlotModel Vertical_Reverse_6()
|
||||
{
|
||||
var model = HeatMapSeriesExamples.CreatePeaks(OxyPalettes.Jet(6), false);
|
||||
var colorAxis = (LinearColorAxis)model.Axes[0];
|
||||
colorAxis.StartPosition = 1;
|
||||
colorAxis.EndPosition = 0;
|
||||
return model;
|
||||
}
|
||||
|
||||
[Example("Horizontal (6 colors)")]
|
||||
public static PlotModel Horizontal_6()
|
||||
{
|
||||
var model = HeatMapSeriesExamples.CreatePeaks(OxyPalettes.Jet(6), false);
|
||||
var colorAxis = (LinearColorAxis)model.Axes[0];
|
||||
colorAxis.Position = AxisPosition.Top;
|
||||
return model;
|
||||
}
|
||||
|
||||
[Example("Horizontal reverse (6 colors)")]
|
||||
public static PlotModel Horizontal_Reverse_6()
|
||||
{
|
||||
var model = HeatMapSeriesExamples.CreatePeaks(OxyPalettes.Jet(6), false);
|
||||
var colorAxis = (LinearColorAxis)model.Axes[0];
|
||||
colorAxis.Position = AxisPosition.Top;
|
||||
colorAxis.StartPosition = 1;
|
||||
colorAxis.EndPosition = 0;
|
||||
return model;
|
||||
}
|
||||
|
||||
[Example("RenderAsImage (horizontal)")]
|
||||
public static PlotModel RenderAsImage_Horizontal()
|
||||
{
|
||||
var model = HeatMapSeriesExamples.CreatePeaks(OxyPalettes.Jet(1000), false);
|
||||
var colorAxis = (LinearColorAxis)model.Axes[0];
|
||||
colorAxis.RenderAsImage = true;
|
||||
colorAxis.Position = AxisPosition.Top;
|
||||
return model;
|
||||
}
|
||||
|
||||
[Example("RenderAsImage (horizontal reversed)")]
|
||||
public static PlotModel RenderAsImage_Horizontal_Reversed()
|
||||
{
|
||||
var model = HeatMapSeriesExamples.CreatePeaks(OxyPalettes.Jet(1000), false);
|
||||
var colorAxis = (LinearColorAxis)model.Axes[0];
|
||||
colorAxis.RenderAsImage = true;
|
||||
colorAxis.Position = AxisPosition.Top;
|
||||
colorAxis.StartPosition = 1;
|
||||
colorAxis.EndPosition = 0;
|
||||
return model;
|
||||
}
|
||||
|
||||
[Example("RenderAsImage (vertical)")]
|
||||
public static PlotModel RenderAsImage_Vertical()
|
||||
{
|
||||
var model = HeatMapSeriesExamples.CreatePeaks(OxyPalettes.Jet(1000), false);
|
||||
var colorAxis = (LinearColorAxis)model.Axes[0];
|
||||
colorAxis.RenderAsImage = true;
|
||||
return model;
|
||||
}
|
||||
|
||||
[Example("RenderAsImage (vertical reversed)")]
|
||||
public static PlotModel RenderAsImage_Vertical_Reversed()
|
||||
{
|
||||
var model = HeatMapSeriesExamples.CreatePeaks(OxyPalettes.Jet(1000), false);
|
||||
var colorAxis = (LinearColorAxis)model.Axes[0];
|
||||
colorAxis.RenderAsImage = true;
|
||||
colorAxis.StartPosition = 1;
|
||||
colorAxis.EndPosition = 0;
|
||||
return model;
|
||||
}
|
||||
|
||||
[Example("Short vertical")]
|
||||
public static PlotModel Vertical_Short()
|
||||
{
|
||||
var model = HeatMapSeriesExamples.CreatePeaks(OxyPalettes.Jet(600), false);
|
||||
var colorAxis = (LinearColorAxis)model.Axes[0];
|
||||
colorAxis.StartPosition = 0.02;
|
||||
colorAxis.EndPosition = 0.5;
|
||||
return model;
|
||||
}
|
||||
|
||||
[Example("Position None")]
|
||||
public static PlotModel Position_None()
|
||||
{
|
||||
var model = HeatMapSeriesExamples.CreatePeaks(OxyPalettes.Jet(600), false);
|
||||
var colorAxis = (LinearColorAxis)model.Axes[0];
|
||||
colorAxis.Position = AxisPosition.None;
|
||||
return model;
|
||||
}
|
||||
}
|
||||
}
|
||||
176
Source/Examples/ExampleLibrary/Axes/LogarithmicAxisExamples.cs
Normal file
176
Source/Examples/ExampleLibrary/Axes/LogarithmicAxisExamples.cs
Normal file
@@ -0,0 +1,176 @@
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
// <copyright file="LogarithmicAxisExamples.cs" company="OxyPlot">
|
||||
// Copyright (c) 2014 OxyPlot contributors
|
||||
// </copyright>
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
namespace ExampleLibrary
|
||||
{
|
||||
using System;
|
||||
|
||||
using OxyPlot;
|
||||
using OxyPlot.Axes;
|
||||
using OxyPlot.Series;
|
||||
using OxyPlot.Legends;
|
||||
|
||||
[Examples("LogarithmicAxis"), Tags("Axes")]
|
||||
public static class LogarithmicAxisExamples
|
||||
{
|
||||
[Example("LogarithmicAxis with default values")]
|
||||
public static PlotModel DefaultValues()
|
||||
{
|
||||
var m = new PlotModel();
|
||||
m.Axes.Add(new LogarithmicAxis { Position = AxisPosition.Bottom });
|
||||
m.Axes.Add(new LogarithmicAxis { Position = AxisPosition.Left});
|
||||
return m;
|
||||
}
|
||||
|
||||
[Example("Amdahl's Law")]
|
||||
public static PlotModel AmdahlsLaw()
|
||||
{
|
||||
var model = new PlotModel { Title = "Amdahl's law" };
|
||||
|
||||
Legend l = new Legend
|
||||
{
|
||||
LegendTitle = "Parallel portion"
|
||||
};
|
||||
model.Legends.Add(l);
|
||||
|
||||
// http://en.wikipedia.org/wiki/Amdahl's_law
|
||||
Func<double, int, double> maxSpeedup = (p, n) => 1.0 / ((1.0 - p) + (double)p / n);
|
||||
Func<double, LineSeries> createSpeedupCurve = p =>
|
||||
{
|
||||
// todo: tracker does not work when smoothing = true (too few points interpolated on the left end of the curve)
|
||||
var ls = new LineSeries { Title = p.ToString("P0") };
|
||||
for (int n = 1; n <= 65536; n *= 2) ls.Points.Add(new DataPoint(n, maxSpeedup(p, n)));
|
||||
return ls;
|
||||
};
|
||||
model.Axes.Add(new LogarithmicAxis { Position = AxisPosition.Bottom, Title = "Number of processors", Base = 2, MajorGridlineStyle = LineStyle.Solid, TickStyle = TickStyle.None });
|
||||
model.Axes.Add(new LinearAxis { Position = AxisPosition.Left, Minimum = 0, Maximum = 20, MinorStep = 2, MajorStep = 2, Title = "Speedup", StringFormat = "F2", MajorGridlineStyle = LineStyle.Solid, TickStyle = TickStyle.None });
|
||||
model.Series.Add(createSpeedupCurve(0.5));
|
||||
model.Series.Add(createSpeedupCurve(0.75));
|
||||
model.Series.Add(createSpeedupCurve(0.9));
|
||||
model.Series.Add(createSpeedupCurve(0.95));
|
||||
|
||||
return model;
|
||||
}
|
||||
|
||||
[Example("Richter magnitudes")]
|
||||
public static PlotModel RichterMagnitudes()
|
||||
{
|
||||
// http://en.wikipedia.org/wiki/Richter_magnitude_scale
|
||||
|
||||
var model = new PlotModel
|
||||
{
|
||||
Title = "The Richter magnitude scale",
|
||||
PlotMargins = new OxyThickness(80, 0, 80, 40),
|
||||
};
|
||||
|
||||
Legend l = new Legend
|
||||
{
|
||||
LegendPlacement = LegendPlacement.Inside,
|
||||
LegendPosition = LegendPosition.TopCenter,
|
||||
LegendOrientation = LegendOrientation.Horizontal,
|
||||
LegendSymbolLength = 24
|
||||
};
|
||||
|
||||
model.Legends.Add(l);
|
||||
|
||||
model.Axes.Add(new LinearAxis { Position = AxisPosition.Bottom, Title = "Richter magnitude scale", MajorGridlineStyle = LineStyle.None, TickStyle = TickStyle.None });
|
||||
|
||||
var frequencyCurve = new LineSeries
|
||||
{
|
||||
Title = "Frequency",
|
||||
Color = OxyColor.FromUInt32(0xff3c6c9e),
|
||||
StrokeThickness = 3,
|
||||
MarkerStroke = OxyColor.FromUInt32(0xff3c6c9e),
|
||||
MarkerFill = OxyColors.White,
|
||||
MarkerType = MarkerType.Circle,
|
||||
MarkerSize = 4,
|
||||
MarkerStrokeThickness = 3
|
||||
};
|
||||
|
||||
frequencyCurve.Points.Add(new DataPoint(1.5, 8000 * 365 * 100));
|
||||
frequencyCurve.Points.Add(new DataPoint(2.5, 1000 * 365 * 100));
|
||||
frequencyCurve.Points.Add(new DataPoint(3.5, 49000 * 100));
|
||||
frequencyCurve.Points.Add(new DataPoint(4.5, 6200 * 100));
|
||||
frequencyCurve.Points.Add(new DataPoint(5.5, 800 * 100));
|
||||
frequencyCurve.Points.Add(new DataPoint(6.5, 120 * 100));
|
||||
frequencyCurve.Points.Add(new DataPoint(7.5, 18 * 100));
|
||||
frequencyCurve.Points.Add(new DataPoint(8.5, 1 * 100));
|
||||
frequencyCurve.Points.Add(new DataPoint(9.5, 1.0 / 20 * 100));
|
||||
model.Axes.Add(new LogarithmicAxis { Position = AxisPosition.Left, Title = "Frequency / 100 yr", UseSuperExponentialFormat = true, MajorGridlineStyle = LineStyle.None, TickStyle = TickStyle.Outside });
|
||||
model.Series.Add(frequencyCurve);
|
||||
|
||||
var energyCurve = new LineSeries
|
||||
{
|
||||
Title = "Energy",
|
||||
Color = OxyColor.FromUInt32(0xff9e6c3c),
|
||||
StrokeThickness = 3,
|
||||
MarkerStroke = OxyColor.FromUInt32(0xff9e6c3c),
|
||||
MarkerFill = OxyColors.White,
|
||||
MarkerType = MarkerType.Circle,
|
||||
MarkerSize = 4,
|
||||
MarkerStrokeThickness = 3
|
||||
};
|
||||
|
||||
energyCurve.Points.Add(new DataPoint(1.5, 11e6));
|
||||
energyCurve.Points.Add(new DataPoint(2.5, 360e6));
|
||||
energyCurve.Points.Add(new DataPoint(3.5, 11e9));
|
||||
energyCurve.Points.Add(new DataPoint(4.5, 360e9));
|
||||
energyCurve.Points.Add(new DataPoint(5.5, 11e12));
|
||||
energyCurve.Points.Add(new DataPoint(6.5, 360e12));
|
||||
energyCurve.Points.Add(new DataPoint(7.5, 11e15));
|
||||
energyCurve.Points.Add(new DataPoint(8.5, 360e15));
|
||||
energyCurve.Points.Add(new DataPoint(9.5, 11e18));
|
||||
energyCurve.YAxisKey = "energyAxis";
|
||||
|
||||
model.Axes.Add(new LogarithmicAxis { Position = AxisPosition.Right, Title = "Energy / J", Key = "energyAxis", UseSuperExponentialFormat = true, MajorGridlineStyle = LineStyle.None, TickStyle = TickStyle.Outside });
|
||||
model.Series.Add(energyCurve);
|
||||
|
||||
return model;
|
||||
}
|
||||
|
||||
[Example("LogarithmicAxis with AbsoluteMaximum")]
|
||||
public static PlotModel AbsoluteMaximum()
|
||||
{
|
||||
var model = new PlotModel { Title = "AbsoluteMaximum = 1000" };
|
||||
model.Axes.Add(new LogarithmicAxis { Position = AxisPosition.Left, Minimum = 0.1, Maximum = 1000, AbsoluteMaximum = 1000 });
|
||||
model.Series.Add(new FunctionSeries(Math.Exp, 0, Math.Log(900), 100));
|
||||
return model;
|
||||
}
|
||||
|
||||
[Example("LogarithmicAxis with AxisChanged event handler")]
|
||||
public static PlotModel AxisChangedEventHAndler()
|
||||
{
|
||||
var model = new PlotModel { Title = "AxisChanged event handler" };
|
||||
var logAxis = new LogarithmicAxis { Position = AxisPosition.Left, Minimum = 0.1, Maximum = 1000 };
|
||||
int n = 0;
|
||||
logAxis.AxisChanged += (s, e) => { model.Subtitle = "Changed " + (n++) + " times. ActualMaximum=" + logAxis.ActualMaximum; };
|
||||
model.Axes.Add(logAxis);
|
||||
model.Series.Add(new FunctionSeries(Math.Exp, 0, Math.Log(900), 100));
|
||||
return model;
|
||||
}
|
||||
|
||||
[Example("Negative values")]
|
||||
public static PlotModel NegativeValues()
|
||||
{
|
||||
var model = new PlotModel { Title = "LogarithmicAxis", Subtitle = "LineSeries with negative values" };
|
||||
model.Axes.Add(new LogarithmicAxis { Position = AxisPosition.Left });
|
||||
model.Axes.Add(new LinearAxis { Position = AxisPosition.Bottom });
|
||||
model.Series.Add(new FunctionSeries(Math.Sin, 0, 40, 1000));
|
||||
return model;
|
||||
}
|
||||
|
||||
[Example("Tick calculation")]
|
||||
public static PlotModel TickCalculation()
|
||||
{
|
||||
var model = new PlotModel { Title = "Tick calculation for different bases" };
|
||||
model.Axes.Add(new LogarithmicAxis { Title = "Base 10", Position = AxisPosition.Left, Minimum = 20, Maximum = 20000, MajorGridlineStyle = LineStyle.Solid, MinorGridlineStyle = LineStyle.Solid });
|
||||
model.Axes.Add(new LogarithmicAxis { Title = "Base 7", Position = AxisPosition.Bottom, Base = 7, Minimum = 2, Maximum = 10000, MajorGridlineStyle = LineStyle.Solid, MinorGridlineStyle = LineStyle.Solid });
|
||||
model.Axes.Add(new LogarithmicAxis { Title = "Base 5.5", Position = AxisPosition.Top, Base = 5.5, Minimum = 1, Maximum = 100 });
|
||||
model.Axes.Add(new LogarithmicAxis { Title = "Base 2", Position = AxisPosition.Right, Base = 2, Minimum = 1, Maximum = 1000000 });
|
||||
return model;
|
||||
}
|
||||
}
|
||||
}
|
||||
338
Source/Examples/ExampleLibrary/Axes/PolarPlotExamples.cs
Normal file
338
Source/Examples/ExampleLibrary/Axes/PolarPlotExamples.cs
Normal file
@@ -0,0 +1,338 @@
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
// <copyright file="PolarPlotExamples.cs" company="OxyPlot">
|
||||
// Copyright (c) 2014 OxyPlot contributors
|
||||
// </copyright>
|
||||
// <summary>
|
||||
// Shows how to orient 0 degrees at the bottom and add E/W to indicate directions.
|
||||
// </summary>
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
namespace ExampleLibrary
|
||||
{
|
||||
using System;
|
||||
|
||||
using OxyPlot;
|
||||
using OxyPlot.Axes;
|
||||
using OxyPlot.Series;
|
||||
|
||||
[Examples("Polar Plots"), Tags("Axes")]
|
||||
public static class PolarPlotExamples
|
||||
{
|
||||
[Example("Spiral")]
|
||||
public static PlotModel ArchimedeanSpiral()
|
||||
{
|
||||
var model = new PlotModel
|
||||
{
|
||||
Title = "Polar plot",
|
||||
Subtitle = "Archimedean spiral with equation r(θ) = θ for 0 < θ < 6π",
|
||||
PlotType = PlotType.Polar,
|
||||
PlotAreaBorderThickness = new OxyThickness(0),
|
||||
};
|
||||
model.Axes.Add(
|
||||
new AngleAxis
|
||||
{
|
||||
MajorStep = Math.PI / 4,
|
||||
MinorStep = Math.PI / 16,
|
||||
MajorGridlineStyle = LineStyle.Solid,
|
||||
MinorGridlineStyle = LineStyle.Solid,
|
||||
FormatAsFractions = true,
|
||||
FractionUnit = Math.PI,
|
||||
FractionUnitSymbol = "π",
|
||||
Minimum = 0,
|
||||
Maximum = 2 * Math.PI
|
||||
});
|
||||
model.Axes.Add(new MagnitudeAxis
|
||||
{
|
||||
MajorGridlineStyle = LineStyle.Solid,
|
||||
MinorGridlineStyle = LineStyle.Solid,
|
||||
});
|
||||
model.Series.Add(new FunctionSeries(t => t, t => t, 0, Math.PI * 6, 0.01));
|
||||
return model;
|
||||
}
|
||||
|
||||
[Example("Spiral2")]
|
||||
public static PlotModel ArchimedeanSpiral2()
|
||||
{
|
||||
var model = ArchimedeanSpiral();
|
||||
model.Title += "(reversed angle axis)";
|
||||
var angleAxis = (AngleAxis)model.Axes[0];
|
||||
angleAxis.StartAngle = 360;
|
||||
angleAxis.EndAngle = 0;
|
||||
return model;
|
||||
}
|
||||
|
||||
[Example("Spiral with magnitude axis min and max")]
|
||||
public static PlotModel ArchimedeanSpiral3()
|
||||
{
|
||||
var model = ArchimedeanSpiral();
|
||||
model.Title += " (axis Minimum = 10 and Maximum = 20)";
|
||||
var magnitudeAxis = (MagnitudeAxis)model.Axes[1];
|
||||
magnitudeAxis.Minimum = 10;
|
||||
magnitudeAxis.Maximum = 20;
|
||||
return model;
|
||||
}
|
||||
|
||||
[Example("Angle axis with offset angle")]
|
||||
public static PlotModel OffsetAngles()
|
||||
{
|
||||
var model = new PlotModel
|
||||
{
|
||||
Title = "Offset angle axis",
|
||||
PlotType = PlotType.Polar,
|
||||
PlotAreaBorderThickness = new OxyThickness(0),
|
||||
};
|
||||
|
||||
var angleAxis = new AngleAxis
|
||||
{
|
||||
Minimum = 0,
|
||||
Maximum = Math.PI * 2,
|
||||
MajorStep = Math.PI / 4,
|
||||
MinorStep = Math.PI / 16,
|
||||
StringFormat = "0.00",
|
||||
StartAngle = 30,
|
||||
EndAngle = 390
|
||||
};
|
||||
model.Axes.Add(angleAxis);
|
||||
model.Axes.Add(new MagnitudeAxis());
|
||||
model.Series.Add(new FunctionSeries(t => t, t => t, 0, Math.PI * 6, 0.01));
|
||||
|
||||
// Subscribe to the mouse down event on the line series.
|
||||
model.MouseDown += (s, e) =>
|
||||
{
|
||||
var increment = 0d;
|
||||
|
||||
// Increment and decrement must be in degrees (corresponds to the StartAngle and EndAngle properties).
|
||||
if (e.ChangedButton == OxyMouseButton.Left)
|
||||
{
|
||||
increment = 15;
|
||||
}
|
||||
|
||||
if (e.ChangedButton == OxyMouseButton.Right)
|
||||
{
|
||||
increment = -15;
|
||||
}
|
||||
|
||||
if (Math.Abs(increment) > double.Epsilon)
|
||||
{
|
||||
angleAxis.StartAngle += increment;
|
||||
angleAxis.EndAngle += increment;
|
||||
model.InvalidatePlot(false);
|
||||
e.Handled = true;
|
||||
}
|
||||
};
|
||||
|
||||
return model;
|
||||
}
|
||||
|
||||
[Example("Semi-circle")]
|
||||
public static PlotModel SemiCircle()
|
||||
{
|
||||
var model = new PlotModel
|
||||
{
|
||||
Title = "Semi-circle polar plot",
|
||||
PlotType = PlotType.Polar,
|
||||
PlotAreaBorderThickness = new OxyThickness(0),
|
||||
};
|
||||
model.Axes.Add(
|
||||
new AngleAxis
|
||||
{
|
||||
Minimum = 0,
|
||||
Maximum = 180,
|
||||
MajorStep = 45,
|
||||
MinorStep = 9,
|
||||
StartAngle = 0,
|
||||
EndAngle = 180,
|
||||
MajorGridlineStyle = LineStyle.Solid,
|
||||
MinorGridlineStyle = LineStyle.Solid
|
||||
});
|
||||
model.Axes.Add(new MagnitudeAxis
|
||||
{
|
||||
Minimum = 0,
|
||||
Maximum = 1,
|
||||
MajorGridlineStyle = LineStyle.Solid,
|
||||
MinorGridlineStyle = LineStyle.Solid
|
||||
});
|
||||
model.Series.Add(new FunctionSeries(x => Math.Sin(x / 180 * Math.PI), t => t, 0, 180, 0.01));
|
||||
return model;
|
||||
}
|
||||
|
||||
[Example("Semi-circle offset angle axis range")]
|
||||
public static PlotModel SemiCircleOffsetAngleAxisRange()
|
||||
{
|
||||
var model = new PlotModel
|
||||
{
|
||||
Title = "Semi-circle polar plot",
|
||||
Subtitle = "Angle axis range offset to -180 - 180",
|
||||
PlotType = PlotType.Polar,
|
||||
PlotAreaBorderThickness = new OxyThickness(0),
|
||||
};
|
||||
model.Axes.Add(
|
||||
new AngleAxis
|
||||
{
|
||||
Minimum = -180,
|
||||
Maximum = 180,
|
||||
MajorStep = 45,
|
||||
MinorStep = 9,
|
||||
StartAngle = 0,
|
||||
EndAngle = 360,
|
||||
MajorGridlineStyle = LineStyle.Solid,
|
||||
MinorGridlineStyle = LineStyle.Solid
|
||||
});
|
||||
model.Axes.Add(new MagnitudeAxis
|
||||
{
|
||||
Minimum = 0,
|
||||
Maximum = 1,
|
||||
MajorGridlineStyle = LineStyle.Solid,
|
||||
MinorGridlineStyle = LineStyle.Solid
|
||||
});
|
||||
model.Series.Add(new FunctionSeries(x => Math.Sin(x / 180 * Math.PI), t => t, 0, 180, 0.01));
|
||||
return model;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Shows how to orient 0 degrees at the bottom and add E/W to indicate directions.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[Example("East/west directions")]
|
||||
public static PlotModel EastWestDirections()
|
||||
{
|
||||
var model = new PlotModel
|
||||
{
|
||||
Title = "East/west directions",
|
||||
PlotType = PlotType.Polar,
|
||||
PlotAreaBorderThickness = new OxyThickness(0),
|
||||
};
|
||||
model.Axes.Add(
|
||||
new AngleAxis
|
||||
{
|
||||
Minimum = 0,
|
||||
Maximum = 360,
|
||||
MajorStep = 30,
|
||||
MinorStep = 30,
|
||||
StartAngle = -90,
|
||||
EndAngle = 270,
|
||||
LabelFormatter = angle =>
|
||||
{
|
||||
if (angle > 0 && angle < 180)
|
||||
{
|
||||
return angle + "E";
|
||||
}
|
||||
|
||||
if (angle > 180)
|
||||
{
|
||||
return (360 - angle) + "W";
|
||||
}
|
||||
|
||||
return angle.ToString();
|
||||
},
|
||||
MajorGridlineStyle = LineStyle.Dot,
|
||||
MinorGridlineStyle = LineStyle.None
|
||||
});
|
||||
model.Axes.Add(new MagnitudeAxis
|
||||
{
|
||||
Minimum = 0,
|
||||
Maximum = 1,
|
||||
MajorGridlineStyle = LineStyle.Solid,
|
||||
MinorGridlineStyle = LineStyle.Solid
|
||||
});
|
||||
model.Series.Add(new FunctionSeries(x => Math.Sin(x / 180 * Math.PI), t => t, 0, 180, 0.01));
|
||||
return model;
|
||||
}
|
||||
|
||||
[Example("Semi-circle full plot area")]
|
||||
public static PlotModel SemiCircleFullPlotArea()
|
||||
{
|
||||
var model = new PlotModel
|
||||
{
|
||||
Title = "Semi-circle polar plot filling the plot area",
|
||||
Subtitle = "The center can be move using the right mouse button",
|
||||
PlotType = PlotType.Polar,
|
||||
PlotAreaBorderThickness = new OxyThickness(1),
|
||||
};
|
||||
model.Axes.Add(
|
||||
new AngleAxisFullPlotArea
|
||||
{
|
||||
Minimum = 0,
|
||||
Maximum = 180,
|
||||
MajorStep = 45,
|
||||
MinorStep = 9,
|
||||
StartAngle = 0,
|
||||
EndAngle = 180,
|
||||
MajorGridlineStyle = LineStyle.Solid,
|
||||
MinorGridlineStyle = LineStyle.Solid
|
||||
});
|
||||
model.Axes.Add(new MagnitudeAxisFullPlotArea
|
||||
{
|
||||
Minimum = 0,
|
||||
Maximum = 1,
|
||||
MidshiftH = 0,
|
||||
MidshiftV = 0.9d,
|
||||
MajorGridlineStyle = LineStyle.Solid,
|
||||
MinorGridlineStyle = LineStyle.Solid
|
||||
});
|
||||
model.Series.Add(new FunctionSeries(x => Math.Sin(x / 180 * Math.PI), t => t, 0, 180, 0.01));
|
||||
return model;
|
||||
}
|
||||
|
||||
[Example("Spiral full plot area")]
|
||||
public static PlotModel ArchimedeanSpiralFullPlotArea()
|
||||
{
|
||||
var model = CreateFullPlotAreaPlotModel();
|
||||
model.Series.Add(new FunctionSeries(t => t, t => t, 0, Math.PI * 6, 0.01));
|
||||
return model;
|
||||
}
|
||||
|
||||
[Example("Spiral full plot area with negative minimum")]
|
||||
public static PlotModel SpiralWithNegativeMinium()
|
||||
{
|
||||
var model = CreateFullPlotAreaPlotModel();
|
||||
model.Title += " with a negative minimum";
|
||||
model.Series.Add(new FunctionSeries(t => t, t => t, -Math.PI * 6, Math.PI * 6, 0.01));
|
||||
return model;
|
||||
}
|
||||
|
||||
[Example("Spiral full plot area with positive minimum")]
|
||||
public static PlotModel SpiralWithPositiveMinium()
|
||||
{
|
||||
var model = CreateFullPlotAreaPlotModel();
|
||||
model.Title += " with a positive minimum";
|
||||
model.Series.Add(new FunctionSeries(t => t, t => t, Math.PI * 6, Math.PI * 12, 0.01));
|
||||
return model;
|
||||
}
|
||||
|
||||
private static PlotModel CreateFullPlotAreaPlotModel()
|
||||
{
|
||||
var model = new PlotModel
|
||||
{
|
||||
Title = "Polar plot filling the plot area",
|
||||
Subtitle = "The center can be move using the right mouse button",
|
||||
PlotType = PlotType.Polar,
|
||||
PlotAreaBorderThickness = new OxyThickness(1),
|
||||
};
|
||||
|
||||
model.Axes.Add(
|
||||
new AngleAxisFullPlotArea
|
||||
{
|
||||
MajorStep = Math.PI / 4,
|
||||
MinorStep = Math.PI / 16,
|
||||
MajorGridlineStyle = LineStyle.Solid,
|
||||
MinorGridlineStyle = LineStyle.Solid,
|
||||
FormatAsFractions = true,
|
||||
FractionUnit = Math.PI,
|
||||
FractionUnitSymbol = "π",
|
||||
Minimum = 0,
|
||||
Maximum = 2 * Math.PI
|
||||
});
|
||||
|
||||
model.Axes.Add(new MagnitudeAxisFullPlotArea
|
||||
{
|
||||
MidshiftH = -0.1d,
|
||||
MidshiftV = -0.25d,
|
||||
MajorGridlineStyle = LineStyle.Solid,
|
||||
MinorGridlineStyle = LineStyle.Solid
|
||||
});
|
||||
|
||||
return model;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
// <copyright file="RangeColorAxisExamples.cs" company="OxyPlot">
|
||||
// Copyright (c) 2014 OxyPlot contributors
|
||||
// </copyright>
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
namespace ExampleLibrary
|
||||
{
|
||||
using System;
|
||||
|
||||
using OxyPlot;
|
||||
using OxyPlot.Axes;
|
||||
using OxyPlot.Series;
|
||||
|
||||
[Examples("RangeColorAxis"), Tags("Axes")]
|
||||
public class RangeColorAxisExamples
|
||||
{
|
||||
[Example("ScatterSeries with Reversed RangeColorAxis (Horizontal)")]
|
||||
public static PlotModel ReversedHorizontalRangeColorAxis()
|
||||
{
|
||||
return RangeColorAxis(AxisPosition.Top, true);
|
||||
}
|
||||
|
||||
[Example("ScatterSeries with Reversed RangeColorAxis (Vertical)")]
|
||||
public static PlotModel ReversedVerticalRangeColorAxis()
|
||||
{
|
||||
return RangeColorAxis(AxisPosition.Right, true);
|
||||
}
|
||||
|
||||
[Example("ScatterSeries with RangeColorAxis (Horizontal)")]
|
||||
public static PlotModel HorizontalRangeColorAxis()
|
||||
{
|
||||
return RangeColorAxis(AxisPosition.Top, false);
|
||||
}
|
||||
|
||||
[Example("ScatterSeries with RangeColorAxis (Vertical)")]
|
||||
public static PlotModel VerticalRangeColorAxis()
|
||||
{
|
||||
return RangeColorAxis(AxisPosition.Right, false);
|
||||
}
|
||||
|
||||
private static PlotModel RangeColorAxis(AxisPosition position, bool reverseAxis)
|
||||
{
|
||||
int n = 1000;
|
||||
|
||||
string modelTitle = reverseAxis
|
||||
? string.Format("ScatterSeries and Reversed RangeColorAxis (n={0})", n)
|
||||
: string.Format("ScatterSeries and RangeColorAxis (n={0})", n);
|
||||
|
||||
var model = new PlotModel
|
||||
{
|
||||
Title = modelTitle,
|
||||
Background = OxyColors.LightGray
|
||||
};
|
||||
|
||||
model.Axes.Add(new LinearAxis { Position = AxisPosition.Bottom });
|
||||
model.Axes.Add(new LinearAxis { Position = AxisPosition.Left });
|
||||
|
||||
var rca = new RangeColorAxis { Position = position, Maximum = 2, Minimum = -2 };
|
||||
rca.AddRange(0, 0.5, OxyColors.Blue);
|
||||
rca.AddRange(-0.2, -0.1, OxyColors.Red);
|
||||
|
||||
if (reverseAxis)
|
||||
{
|
||||
rca.StartPosition = 1;
|
||||
rca.EndPosition = 0;
|
||||
}
|
||||
|
||||
model.Axes.Add(rca);
|
||||
|
||||
var s1 = new ScatterSeries { MarkerType = MarkerType.Square, MarkerSize = 6, };
|
||||
|
||||
var random = new Random(13);
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
double x = (random.NextDouble() * 2.2) - 1.1;
|
||||
s1.Points.Add(new ScatterPoint(x, random.NextDouble()) { Value = x });
|
||||
}
|
||||
|
||||
model.Series.Add(s1);
|
||||
return model;
|
||||
}
|
||||
}
|
||||
}
|
||||
74
Source/Examples/ExampleLibrary/Axes/TimeSpanAxisExamples.cs
Normal file
74
Source/Examples/ExampleLibrary/Axes/TimeSpanAxisExamples.cs
Normal file
@@ -0,0 +1,74 @@
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
// <copyright file="TimeSpanAxisExamples.cs" company="OxyPlot">
|
||||
// Copyright (c) 2014 OxyPlot contributors
|
||||
// </copyright>
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
namespace ExampleLibrary
|
||||
{
|
||||
using System;
|
||||
using System.Collections.ObjectModel;
|
||||
|
||||
using OxyPlot;
|
||||
using OxyPlot.Axes;
|
||||
using OxyPlot.Series;
|
||||
|
||||
[Examples("TimeSpanAxis"), Tags("Axes")]
|
||||
public static class TimeSpanAxisExamples
|
||||
{
|
||||
public class TimeValue
|
||||
{
|
||||
public TimeSpan Time { get; set; }
|
||||
public double Value { get; set; }
|
||||
}
|
||||
|
||||
[Example("Default StringFormat")]
|
||||
public static PlotModel TimeSpanaxisPlotModelDefault()
|
||||
{
|
||||
return TimeSpanaxisPlotModel(null);
|
||||
}
|
||||
|
||||
[Example("StringFormat = 'h:mm'")]
|
||||
public static PlotModel TimeSpanaxisPlotModel1()
|
||||
{
|
||||
return TimeSpanaxisPlotModel("h:mm");
|
||||
}
|
||||
|
||||
private static PlotModel TimeSpanaxisPlotModel(string stringFormat)
|
||||
{
|
||||
var start = new TimeSpan(0, 0, 0, 0);
|
||||
var end = new TimeSpan(0, 24, 0, 0);
|
||||
double increment = 3600;
|
||||
|
||||
// Create a random data collection
|
||||
var r = new Random(7);
|
||||
var data = new Collection<TimeValue>();
|
||||
var current = start;
|
||||
while (current <= end)
|
||||
{
|
||||
data.Add(new TimeValue { Time = current, Value = r.NextDouble() });
|
||||
current = current.Add(new TimeSpan(0, 0, (int)increment));
|
||||
}
|
||||
|
||||
var plotModel1 = new PlotModel { Title = "TimeSpan axis" };
|
||||
var timeSpanAxis1 = new TimeSpanAxis { Position = AxisPosition.Bottom, StringFormat = stringFormat };
|
||||
plotModel1.Axes.Add(timeSpanAxis1);
|
||||
var linearAxis1 = new LinearAxis { Position = AxisPosition.Left };
|
||||
plotModel1.Axes.Add(linearAxis1);
|
||||
var lineSeries1 = new LineSeries
|
||||
{
|
||||
Color = OxyColor.FromArgb(255, 78, 154, 6),
|
||||
MarkerFill = OxyColor.FromArgb(255, 78, 154, 6),
|
||||
MarkerStroke = OxyColors.ForestGreen,
|
||||
MarkerType = MarkerType.Plus,
|
||||
StrokeThickness = 1,
|
||||
DataFieldX = "Time",
|
||||
DataFieldY = "Value",
|
||||
ItemsSource = data
|
||||
};
|
||||
plotModel1.Series.Add(lineSeries1);
|
||||
return plotModel1;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user