Skip to content

Commit

Permalink
Merge pull request #3 from seijikun/function
Browse files Browse the repository at this point in the history
[FunctionSeries] Add example
  • Loading branch information
objorke committed Apr 3, 2016
2 parents 360a5f8 + 4ef601c commit 8007f83
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
3 changes: 2 additions & 1 deletion ExampleGenerator/ExampleGenerator.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Misc\Showcases.cs" />
<Compile Include="Series\TwoColorLineSeriesExamples.cs" />
<Compile Include="Series\FunctionSeriesExamples.cs" />
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
Expand All @@ -87,4 +88,4 @@
<Target Name="AfterBuild">
</Target>
-->
</Project>
</Project>
32 changes: 32 additions & 0 deletions ExampleGenerator/Series/FunctionSeriesExamples.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using System;

namespace ExampleGenerator
{
using OxyPlot;
using OxyPlot.Axes;
using OxyPlot.Series;

public class FunctionSeriesExamples
{
[Export(@"Series\FunctionSeries")]
public static PlotModel FunctionSeries()
{
var model = new PlotModel{ Title = "Fun with Bats" };

Func<double, double> batFn1 = (x) => 2 * Math.Sqrt(-Math.Abs(Math.Abs(x) - 1) * Math.Abs(3 - Math.Abs(x)) / ((Math.Abs(x) - 1) * (3 - Math.Abs(x)))) * (1 + Math.Abs(Math.Abs(x) - 3) / (Math.Abs(x) - 3)) * Math.Sqrt(1 - Math.Pow((x / 7), 2)) + (5 + 0.97 * (Math.Abs(x - 0.5) + Math.Abs(x + 0.5)) - 3 * (Math.Abs(x - 0.75) + Math.Abs(x + 0.75))) * (1 + Math.Abs(1 - Math.Abs(x)) / (1 - Math.Abs(x)));
Func<double, double> batFn2 = (x) => -3 * Math.Sqrt(1 - Math.Pow((x / 7), 2)) * Math.Sqrt(Math.Abs(Math.Abs(x) - 4) / (Math.Abs(x) - 4));
Func<double, double> batFn3 = (x) => Math.Abs(x / 2) - 0.0913722 * (Math.Pow(x, 2)) - 3 + Math.Sqrt(1 - Math.Pow((Math.Abs(Math.Abs(x) - 2) - 1), 2));
Func<double, double> batFn4 = (x) => (2.71052 + (1.5 - .5 * Math.Abs(x)) - 1.35526 * Math.Sqrt(4 - Math.Pow((Math.Abs(x) - 1), 2))) * Math.Sqrt(Math.Abs(Math.Abs(x) - 1) / (Math.Abs(x) - 1)) + 0.9;

model.Series.Add(new FunctionSeries(batFn1, -8, 8, 0.0001));
model.Series.Add(new FunctionSeries(batFn2, -8, 8, 0.0001));
model.Series.Add(new FunctionSeries(batFn3, -8, 8, 0.0001));
model.Series.Add(new FunctionSeries(batFn4, -8, 8, 0.0001));

model.Axes.Add(new LinearAxis{ Position = AxisPosition.Bottom, MaximumPadding = 0.1, MinimumPadding = 0.1 });
model.Axes.Add(new LinearAxis{ Position = AxisPosition.Left, MaximumPadding = 0.1, MinimumPadding = 0.1 });

return model;
}
}
}

0 comments on commit 8007f83

Please sign in to comment.