Skip to content

Commit

Permalink
Add ThreeColorLineSeries (oxyplot#378)
Browse files Browse the repository at this point in the history
  • Loading branch information
objorke committed Sep 11, 2015
1 parent 3d5841c commit 8a33b32
Show file tree
Hide file tree
Showing 14 changed files with 544 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ All notable changes to this project will be documented in this file.
- Added LinearBarSeries for WPF (#506)
- Added TitleToolTip to PlotModel (#508)
- Expose PlotElement's TextColor property on WPF.Axes.Axis (#452)
- ThreeColorLineSeries (#378)

### Changed
- Renamed OxyPlot.WindowsUniversal to OxyPlot.Windows (#242)
Expand Down
1 change: 1 addition & 0 deletions CONTRIBUTORS
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ Kevin Crowell <[email protected]>
LECO® Corporation
Levi Botelho <[email protected]>
lsowen
Luka B
Matthew Leibowitz <[email protected]>
Memphisch <[email protected]>
Mendel Monteiro-Beckerman
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public static PlotModel AbsoluteYminYmaxXminXmax()
return plot;
}

private static Series CreateTestSeries()
private static OxyPlot.Series.Series CreateTestSeries()
{
var absSerie = new LineSeries();

Expand Down
1 change: 1 addition & 0 deletions Source/Examples/ExampleLibrary/ExampleLibrary.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
<Compile Include="Series\ContourSeriesExamples.cs" />
<Compile Include="Series\IntervalBarSeriesExamples.cs" />
<Compile Include="Series\RectangleBarSeriesExamples.cs" />
<Compile Include="Series\ThreeColorLineSeriesExamples.cs" />
<Compile Include="Series\TornadoBarSeriesExamples.cs" />
<Compile Include="Examples\PlotControllerExamples.cs" />
<Compile Include="Axes\CustomAxisExamples.cs" />
Expand Down
1 change: 1 addition & 0 deletions Source/Examples/ExampleLibrary/ExampleLibrary_NET40.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@
<Compile Include="Series\ContourSeriesExamples.cs" />
<Compile Include="Series\IntervalBarSeriesExamples.cs" />
<Compile Include="Series\RectangleBarSeriesExamples.cs" />
<Compile Include="Series\ThreeColorLineSeriesExamples.cs" />
<Compile Include="Series\TornadoBarSeriesExamples.cs" />
<Compile Include="Examples\PlotControllerExamples.cs" />
<Compile Include="Axes\CustomAxisExamples.cs" />
Expand Down
1 change: 1 addition & 0 deletions Source/Examples/ExampleLibrary/ExampleLibrary_SL5.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@
<Compile Include="Series\ContourSeriesExamples.cs" />
<Compile Include="Series\IntervalBarSeriesExamples.cs" />
<Compile Include="Series\RectangleBarSeriesExamples.cs" />
<Compile Include="Series\ThreeColorLineSeriesExamples.cs" />
<Compile Include="Series\TornadoBarSeriesExamples.cs" />
<Compile Include="Examples\PlotControllerExamples.cs" />
<Compile Include="Axes\CustomAxisExamples.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ private static LineSeries CreateSeriesSuitableForDecimation()
return s1;
}

private static Series CreateRandomLineSeries(int n, string title, MarkerType markerType)
private static OxyPlot.Series.Series CreateRandomLineSeries(int n, string title, MarkerType markerType)
{
var s1 = new LineSeries { Title = title, MarkerType = markerType, MarkerStroke = OxyColors.Black, MarkerStrokeThickness = 1.0 };
double x = 0;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="ThreeColorLineSeriesExamples.cs" company="OxyPlot">
// Copyright (c) 2014 OxyPlot contributors
// </copyright>
// <summary>
// Provides examples for the ThreeColorLineSeries.
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace ExampleLibrary.Series
{
using OxyPlot;
using OxyPlot.Axes;
using OxyPlot.Series;
using System;

/// <summary>
/// Provides examples for the <see cref="ThreeColorLineSeries" />.
/// </summary>
[Examples("ThreeColorLineSeries"), Tags("Series")]
public class ThreeColorLineSeriesExamples
{
/// <summary>
/// Creates an example showing temperatures.
/// </summary>
/// <returns>A <see cref="PlotModel" />.</returns>
[Example("Temperatures")]
public static PlotModel ThreeColorLineSeries()
{
var plotModel1 = new PlotModel();
plotModel1.LegendSymbolLength = 24;
plotModel1.Title = "ThreeColorLineSeries";
var linearAxis1 = new LinearAxis();
linearAxis1.Title = "Temperature";
linearAxis1.Unit = "°C";
linearAxis1.ExtraGridlines = new Double[1];
linearAxis1.ExtraGridlines[0] = 0;
plotModel1.Axes.Add(linearAxis1);
var linearAxis2 = new LinearAxis();
linearAxis2.Position = AxisPosition.Bottom;
linearAxis2.Title = "Date";
plotModel1.Axes.Add(linearAxis2);
var twoColorLineSeries1 = new ThreeColorLineSeries();
twoColorLineSeries1.MarkerSize = 4;
twoColorLineSeries1.MarkerStroke = OxyColors.Black;
twoColorLineSeries1.MarkerStrokeThickness = 1.5;
twoColorLineSeries1.MarkerType = MarkerType.Circle;
//twoColorLineSeries1.Smooth = true;
twoColorLineSeries1.StrokeThickness = 3;
twoColorLineSeries1.Title = "Temperature Example";
twoColorLineSeries1.TrackerFormatString = "December {2:0}: {4:0.0} °C";
twoColorLineSeries1.Points.Add(new DataPoint(1, 5));
twoColorLineSeries1.Points.Add(new DataPoint(2, 0));
twoColorLineSeries1.Points.Add(new DataPoint(3, 7));
twoColorLineSeries1.Points.Add(new DataPoint(4, 7));
twoColorLineSeries1.Points.Add(new DataPoint(5, 4));
twoColorLineSeries1.Points.Add(new DataPoint(6, 3));
twoColorLineSeries1.Points.Add(new DataPoint(7, 5));
twoColorLineSeries1.Points.Add(new DataPoint(8, 5));
twoColorLineSeries1.Points.Add(new DataPoint(9, 11));
twoColorLineSeries1.Points.Add(new DataPoint(10, 4));
twoColorLineSeries1.Points.Add(new DataPoint(11, 2));
twoColorLineSeries1.Points.Add(new DataPoint(12, 3));
twoColorLineSeries1.Points.Add(new DataPoint(13, 2));
twoColorLineSeries1.Points.Add(new DataPoint(14, 1));
twoColorLineSeries1.Points.Add(new DataPoint(15, 0));
twoColorLineSeries1.Points.Add(new DataPoint(16, 2));
twoColorLineSeries1.Points.Add(new DataPoint(17, -1));
twoColorLineSeries1.Points.Add(new DataPoint(18, 0));
twoColorLineSeries1.Points.Add(new DataPoint(19, 0));
twoColorLineSeries1.Points.Add(new DataPoint(20, -3));
twoColorLineSeries1.Points.Add(new DataPoint(21, -6));
twoColorLineSeries1.Points.Add(new DataPoint(22, -13));
twoColorLineSeries1.Points.Add(new DataPoint(23, -10));
twoColorLineSeries1.Points.Add(new DataPoint(24, -10));
twoColorLineSeries1.Points.Add(new DataPoint(25, 0));
twoColorLineSeries1.Points.Add(new DataPoint(26, -4));
twoColorLineSeries1.Points.Add(new DataPoint(27, -5));
twoColorLineSeries1.Points.Add(new DataPoint(28, -4));
twoColorLineSeries1.Points.Add(new DataPoint(29, 3));
twoColorLineSeries1.Points.Add(new DataPoint(30, 0));
twoColorLineSeries1.Points.Add(new DataPoint(31, -5));

twoColorLineSeries1.Points.Add(new DataPoint(32, -20));
twoColorLineSeries1.Points.Add(new DataPoint(33, -20));
twoColorLineSeries1.Points.Add(new DataPoint(34, 20));
twoColorLineSeries1.Points.Add(new DataPoint(35, 20));
plotModel1.Series.Add(twoColorLineSeries1);
return plotModel1;
}
}
}
1 change: 1 addition & 0 deletions Source/OxyPlot.Wpf/OxyPlot.Wpf.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@
<Compile Include="Series\BarSeries\CategorizedSeries.cs" />
<Compile Include="Series\BarSeries\BarSeriesBase.cs" />
<Compile Include="Series\BarSeries\BarSeriesBase{T}.cs" />
<Compile Include="Series\ThreeColorLineSeries.cs" />
<Compile Include="Series\TwoColorAreaSeries.cs" />
<Compile Include="SvgExporter.cs" />
<Compile Include="TextMeasurementMethod.cs" />
Expand Down
180 changes: 180 additions & 0 deletions Source/OxyPlot.Wpf/Series/ThreeColorLineSeries.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,180 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="ThreeColorLineSeries.cs" company="OxyPlot">
// Copyright (c) 2014 OxyPlot contributors
// </copyright>
// <summary>
// The WPF wrapper for OxyPlot.ThreeColorLineSeries.
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace OxyPlot.Wpf
{
using System.Windows;
using System.Windows.Media;

/// <summary>
/// The WPF wrapper for OxyPlot.ThreeColorLineSeries.
/// </summary>
public class ThreeColorLineSeries : LineSeries
{
/// <summary>
/// Identifies the <see cref="ColorLo"/> dependency property.
/// </summary>
public static readonly DependencyProperty ColorLoProperty = DependencyProperty.Register(
"ColorLo", typeof(Color), typeof(ThreeColorLineSeries), new UIPropertyMetadata(Colors.Blue, AppearanceChanged));

/// <summary>
/// Identifies the <see cref="ColorHi"/> dependency property.
/// </summary>
public static readonly DependencyProperty ColorHiProperty = DependencyProperty.Register(
"ColorHi", typeof(Color), typeof(ThreeColorLineSeries), new UIPropertyMetadata(Colors.Red, AppearanceChanged));

/// <summary>
/// Identifies the <see cref="LimitLo"/> dependency property.
/// </summary>
public static readonly DependencyProperty LimitLoProperty = DependencyProperty.Register(
"LimitLo", typeof(double), typeof(ThreeColorLineSeries), new UIPropertyMetadata(0.0, AppearanceChanged));

/// <summary>
/// Identifies the <see cref="LimitHi"/> dependency property.
/// </summary>
public static readonly DependencyProperty LimitHiProperty = DependencyProperty.Register(
"LimitHi", typeof(double), typeof(ThreeColorLineSeries), new UIPropertyMetadata(0.0, AppearanceChanged));

/// <summary>
/// Identifies the <see cref="LineStyleLo"/> dependency property.
/// </summary>
public static readonly DependencyProperty LineStyleLoProperty = DependencyProperty.Register(
"LineStyleLo",
typeof(LineStyle),
typeof(ThreeColorLineSeries),
new UIPropertyMetadata(LineStyle.Solid, AppearanceChanged));

/// <summary>
/// Identifies the <see cref="LineStyleHi"/> dependency property.
/// </summary>
public static readonly DependencyProperty LineStyleHiProperty = DependencyProperty.Register(
"LineStyleHi",
typeof(LineStyle),
typeof(ThreeColorLineSeries),
new UIPropertyMetadata(LineStyle.Solid, AppearanceChanged));

/// <summary>
/// Initializes a new instance of the <see cref = "ThreeColorLineSeries" /> class.
/// </summary>
public ThreeColorLineSeries()
{
this.InternalSeries = new OxyPlot.Series.ThreeColorLineSeries();
}

/// <summary>
/// Gets or sets ColorLo.
/// </summary>
public Color ColorLo
{
get
{
return (Color)this.GetValue(ColorLoProperty);
}

set
{
this.SetValue(ColorLoProperty, value);
}
}

/// <summary>
/// Gets or sets ColorHi.
/// </summary>
public Color ColorHi
{
get
{
return (Color)this.GetValue(ColorHiProperty);
}

set
{
this.SetValue(ColorHiProperty, value);
}
}

/// <summary>
/// Gets or sets LimitLo.
/// </summary>
public double LimitLo
{
get
{
return (double)this.GetValue(LimitLoProperty);
}

set
{
this.SetValue(LimitLoProperty, value);
}
}

/// <summary>
/// Gets or sets LimitHi.
/// </summary>
public double LimitHi
{
get
{
return (double)this.GetValue(LimitHiProperty);
}

set
{
this.SetValue(LimitHiProperty, value);
}
}

/// <summary>
/// Gets or sets LineStyleLo.
/// </summary>
public LineStyle LineStyleLo
{
get
{
return (LineStyle)this.GetValue(LineStyleLoProperty);
}

set
{
this.SetValue(LineStyleLoProperty, value);
}
}

/// <summary>
/// Gets or sets LineStyleHi.
/// </summary>
public LineStyle LineStyleHi
{
get
{
return (LineStyle)this.GetValue(LineStyleHiProperty);
}

set
{
this.SetValue(LineStyleHiProperty, value);
}
}

/// <summary>
/// Synchronizes the properties.
/// </summary>
/// <param name="series">The series.</param>
protected override void SynchronizeProperties(OxyPlot.Series.Series series)
{
base.SynchronizeProperties(series);
var s = series as OxyPlot.Series.ThreeColorLineSeries;
s.LimitLo = this.LimitLo;
s.ColorLo = this.ColorLo.ToOxyColor();
s.LimitHi = this.LimitHi;
s.ColorHi = this.ColorHi.ToOxyColor();
}
}
}
1 change: 1 addition & 0 deletions Source/OxyPlot/OxyPlot.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@
<Compile Include="Series\ScatterErrorPoint.cs" />
<Compile Include="Series\ScatterErrorSeries.cs" />
<Compile Include="Series\ScatterSeries{T}.cs" />
<Compile Include="Series\ThreeColorLineSeries.cs" />
<Compile Include="Utilities\ArrayExtensions.cs" />
<Compile Include="Utilities\ComparerHelper.cs" />
<Compile Include="Utilities\EnumerableExtensions.cs" />
Expand Down
1 change: 1 addition & 0 deletions Source/OxyPlot/OxyPlot_NET40.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@
<Compile Include="Series\ScatterErrorPoint.cs" />
<Compile Include="Series\ScatterErrorSeries.cs" />
<Compile Include="Series\ScatterSeries{T}.cs" />
<Compile Include="Series\ThreeColorLineSeries.cs" />
<Compile Include="Utilities\ArrayExtensions.cs" />
<Compile Include="Utilities\ComparerHelper.cs" />
<Compile Include="Utilities\EnumerableExtensions.cs" />
Expand Down
1 change: 1 addition & 0 deletions Source/OxyPlot/OxyPlot_SL5.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@
<Compile Include="Series\ScatterErrorPoint.cs" />
<Compile Include="Series\ScatterErrorSeries.cs" />
<Compile Include="Series\ScatterSeries{T}.cs" />
<Compile Include="Series\ThreeColorLineSeries.cs" />
<Compile Include="Utilities\ArrayExtensions.cs" />
<Compile Include="Utilities\ComparerHelper.cs" />
<Compile Include="Utilities\EnumerableExtensions.cs" />
Expand Down
Loading

0 comments on commit 8a33b32

Please sign in to comment.