Skip to content

Commit 5744f7f

Browse files
committed
Add Support for transposed XYAxisSeries (#1334)
1 parent 05b527e commit 5744f7f

41 files changed

Lines changed: 925 additions & 585 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ All notable changes to this project will be documented in this file.
2020
- Multiline text support for PortableDocumentFont (#1146)
2121
- Workaround for text vertical alignment in SVG Export to accomodate viewers which don't support dominant-baseline (#459, #1198)
2222
- Issues Example demonstrating the rendering of Line and Arrow annotations with all LineStyles (#1312)
23+
- Add support for transposed (X and Y axis switched) plots with XYAxisSeries (#1334)
2324

2425
### Changed
2526
- Let Gtk# PlotView show up in Ui editor ToolBox of MonoDevelop and XamarinStudio (#1071)
@@ -63,6 +64,10 @@ All notable changes to this project will be documented in this file.
6364
- Fixed references to RectangleItem in HistogramSeries
6465
- Fix AxisChangedEventArgs.DeltaMaximum in Axes.Reset (#1306)
6566
- Fixed Tracker for RectangleBarSeries (#1171)
67+
- Fix: RectangleSeries doesn't render Labels (related to #1334)
68+
- Fix: LineSeries line legend placement with reversed X axis (related to #1334)
69+
- Fix: HistogramSeries label placement inconsistent (related to #1334)
70+
- Fix: TwoColorLineSeries and ThreeColorLineSeries don't work with reversed Y axis (related to #1334)
6671

6772
## [1.0.0] - 2016-09-11
6873
### Added

Source/Examples/ExampleLibrary/Series/AreaSeriesExamples.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
namespace ExampleLibrary
88
{
9+
using ExampleLibrary.Utilities;
10+
911
using OxyPlot;
1012
using OxyPlot.Axes;
1113
using OxyPlot.Series;
@@ -21,6 +23,12 @@ public static PlotModel DefaultStyle()
2123
return plotModel1;
2224
}
2325

26+
[Example("Default style (transposed)")]
27+
public static PlotModel DefaultStyleTransposed()
28+
{
29+
return DefaultStyle().Transpose();
30+
}
31+
2432
[Example("Different stroke colors")]
2533
public static PlotModel DifferentColors()
2634
{
@@ -448,4 +456,4 @@ private static AreaSeries CreateExampleAreaSeries()
448456
return areaSeries1;
449457
}
450458
}
451-
}
459+
}

Source/Examples/ExampleLibrary/Series/BoxPlotSeriesExamples.cs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ namespace ExampleLibrary
1313
using System.Collections.Generic;
1414
using System.Linq;
1515

16+
using ExampleLibrary.Utilities;
17+
1618
using OxyPlot;
1719
using OxyPlot.Annotations;
1820
using OxyPlot.Axes;
@@ -29,10 +31,10 @@ public static PlotModel BoxPlot()
2931
var model = new PlotModel { Title = string.Format("BoxPlot (n={0})", boxes), LegendPlacement = LegendPlacement.Outside };
3032

3133
var s1 = new BoxPlotSeries
32-
{
33-
Title = "BoxPlotSeries",
34-
BoxWidth = 0.3
35-
};
34+
{
35+
Title = "BoxPlotSeries",
36+
BoxWidth = 0.3
37+
};
3638

3739
var random = new Random(31);
3840
for (var i = 0; i < boxes; i++)
@@ -70,6 +72,12 @@ public static PlotModel BoxPlot()
7072
return model;
7173
}
7274

75+
[Example("BoxPlot (transposed)")]
76+
public static PlotModel BoxPlotTransposed()
77+
{
78+
return BoxPlot().Transpose();
79+
}
80+
7381
/// <summary>
7482
/// Gets the median.
7583
/// </summary>
@@ -190,4 +198,4 @@ public static PlotModel BoxPlotSeries_DateTimeAxis()
190198
return m;
191199
}
192200
}
193-
}
201+
}

Source/Examples/ExampleLibrary/Series/ContourSeriesExamples.cs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ namespace ExampleLibrary
88
{
99
using System;
1010

11+
using ExampleLibrary.Utilities;
12+
1113
using OxyPlot;
1214
using OxyPlot.Axes;
1315
using OxyPlot.Series;
@@ -25,16 +27,22 @@ public static PlotModel Peaks()
2527
{
2628
var model = new PlotModel { Title = "Peaks" };
2729
var cs = new ContourSeries
28-
{
29-
ColumnCoordinates = ArrayBuilder.CreateVector(-3, 3, 0.05),
30-
RowCoordinates = ArrayBuilder.CreateVector(-3.1, 3.1, 0.05)
31-
};
30+
{
31+
ColumnCoordinates = ArrayBuilder.CreateVector(-3, 3, 0.05),
32+
RowCoordinates = ArrayBuilder.CreateVector(-3.1, 3.1, 0.05)
33+
};
3234
cs.Data = ArrayBuilder.Evaluate(peaks, cs.ColumnCoordinates, cs.RowCoordinates);
3335
model.Subtitle = cs.Data.GetLength(0) + "×" + cs.Data.GetLength(1);
3436
model.Series.Add(cs);
3537
return model;
3638
}
3739

40+
[Example("Peaks (transposed)")]
41+
public static PlotModel PeaksTransposed()
42+
{
43+
return Peaks().Transpose();
44+
}
45+
3846
[Example("Peaks (different contour colors)")]
3947
public static PlotModel PeaksWithColors()
4048
{
@@ -56,6 +64,7 @@ public static PlotModel WideArrayPeaks()
5664
{
5765
var model = new PlotModel { Title = "Peaks" };
5866
model.Axes.Add(new LinearAxis { Position = AxisPosition.Left, Minimum = -3.16262, Maximum = 3.162 });
67+
5968
var cs = new ContourSeries
6069
{
6170
ColumnCoordinates = ArrayBuilder.CreateVector(-3, 3, 0.05),
@@ -66,6 +75,5 @@ public static PlotModel WideArrayPeaks()
6675
model.Series.Add(cs);
6776
return model;
6877
}
69-
7078
}
71-
}
79+
}

Source/Examples/ExampleLibrary/Series/FinancialSeries/CandleStickSeriesExamples.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ namespace ExampleLibrary
99
using System;
1010
using System.Linq;
1111

12+
using ExampleLibrary.Utilities;
13+
1214
using OxyPlot;
1315
using OxyPlot.Axes;
1416
using OxyPlot.Series;
@@ -142,10 +144,17 @@ public static PlotModel SimpleExample()
142144
var series = new CandleStickSeries();
143145
series.Items.Add(new HighLowItem(startTimeValue, 100, 80, 92, 94));
144146
series.Items.Add(new HighLowItem(startTimeValue + 1, 102, 77, 94, 93));
147+
series.Items.Add(new HighLowItem(startTimeValue + 2, 99, 85, 93, 93));
145148
pm.Series.Add(series);
146149
return pm;
147150
}
148151

152+
[Example("Simple CandleStickSeries example (transposed)")]
153+
public static PlotModel SimpleExampleTransposed()
154+
{
155+
return SimpleExample().Transpose();
156+
}
157+
149158
/// <summary>
150159
/// Adjusts the Y extent.
151160
/// </summary>

Source/Examples/ExampleLibrary/Series/FinancialSeries/HighLowSeriesExamples.cs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ namespace ExampleLibrary
88
{
99
using System;
1010

11+
using ExampleLibrary.Utilities;
12+
1113
using OxyPlot;
1214
using OxyPlot.Axes;
1315
using OxyPlot.Series;
@@ -38,6 +40,24 @@ public static PlotModel HighLowSeries()
3840
return model;
3941
}
4042

43+
[Example("HighLowSeries (transposed)")]
44+
public static PlotModel HighLowSeriesTransposed()
45+
{
46+
return HighLowSeries().Transpose();
47+
}
48+
49+
[Example("HighLowSeries (reversed X Axis)")]
50+
public static PlotModel HighLowSeriesReversedXAxis()
51+
{
52+
return HighLowSeries().ReverseXAxis();
53+
}
54+
55+
[Example("HighLowSeries (reversed X Axis, transposed)")]
56+
public static PlotModel HighLowSeriesReversedXAxisTransposed()
57+
{
58+
return HighLowSeriesReversedXAxis().Transpose();
59+
}
60+
4161
[Example("HighLowSeries (DateTime axis)")]
4262
public static PlotModel HighLowSeriesDateTimeAxis()
4363
{
@@ -67,4 +87,4 @@ public static PlotModel HighLowSeriesDateTimeAxis()
6787
return m;
6888
}
6989
}
70-
}
90+
}

Source/Examples/ExampleLibrary/Series/FinancialSeries/VolumeSeriesExamples.cs

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
namespace ExampleLibrary
88
{
9+
using ExampleLibrary.Utilities;
10+
911
using OxyPlot;
1012
using OxyPlot.Axes;
1113
using OxyPlot.Series;
@@ -26,6 +28,12 @@ public static Example JustVolumeCombined_Natural()
2628
return CreateVolumeSeries("Just Volume (combined)", VolumeStyle.Combined, natural: true);
2729
}
2830

31+
[Example("Just Volume (combined), natural axis, transposed")]
32+
public static Example JustVolumeCombined_NaturalTransposed()
33+
{
34+
return CreateVolumeSeries("Just Volume (combined)", VolumeStyle.Combined, natural: true, transposed: true);
35+
}
36+
2937
[Example("Just Volume (stacked), fixed axis")]
3038
public static Example JustVolumeStacked_Fixed()
3139
{
@@ -38,6 +46,12 @@ public static Example JustVolumeStacked_Natural()
3846
return CreateVolumeSeries("Just Volume (stacked)", VolumeStyle.Stacked, natural: true);
3947
}
4048

49+
[Example("Just Volume (stacked), natural axis, transposed")]
50+
public static Example JustVolumeStacked_NaturalTransposed()
51+
{
52+
return CreateVolumeSeries("Just Volume (stacked)", VolumeStyle.Stacked, natural: true, transposed: true);
53+
}
54+
4155
[Example("Just Volume (+/-), fixed axis")]
4256
public static Example JustVolumePositiveNegative_Fixed()
4357
{
@@ -49,6 +63,12 @@ public static Example JustVolumePositiveNegative_Natural()
4963
{
5064
return CreateVolumeSeries("Just Volume (+/-)", VolumeStyle.PositiveNegative, natural: true);
5165
}
66+
67+
[Example("Just Volume (+/-), natural axis, transposed")]
68+
public static Example JustVolumePositiveNegative_NaturalTransposed()
69+
{
70+
return CreateVolumeSeries("Just Volume (+/-)", VolumeStyle.PositiveNegative, natural: true, transposed: true);
71+
}
5272

5373
/// <summary>
5474
/// Creates the volume series.
@@ -58,11 +78,13 @@ public static Example JustVolumePositiveNegative_Natural()
5878
/// <param name="style">Style.</param>
5979
/// <param name="n">N.</param>
6080
/// <param name="natural">If set to <c>true</c> natural.</param>
81+
/// <param name="transposed">If set to <c>true</c> transposed.</param>
6182
private static Example CreateVolumeSeries(
6283
string title,
6384
VolumeStyle style,
6485
int n = 10000,
65-
bool natural = false)
86+
bool natural = false,
87+
bool transposed = false)
6688
{
6789
var pm = new PlotModel { Title = title };
6890

@@ -72,7 +94,8 @@ private static Example CreateVolumeSeries(
7294
NegativeColor = OxyColors.Red,
7395
PositiveHollow = false,
7496
NegativeHollow = false,
75-
VolumeStyle = style
97+
VolumeStyle = style,
98+
Title = "VolumeSeries",
7699
};
77100

78101
// create bars
@@ -94,10 +117,10 @@ private static Example CreateVolumeSeries(
94117
Minimum = Xmin,
95118
Maximum = Xmax
96119
};
120+
97121
var volAxis = new LinearAxis
98122
{
99123
Position = AxisPosition.Left,
100-
Key = "Volume",
101124
StartPosition = 0.0,
102125
EndPosition = 1.0,
103126
Minimum = natural ? double.NaN : 0,
@@ -121,10 +144,15 @@ private static Example CreateVolumeSeries(
121144

122145
pm.Series.Add(series);
123146

147+
if (transposed)
148+
{
149+
pm.Transpose();
150+
}
151+
124152
var controller = new PlotController();
125153
controller.UnbindAll();
126154
controller.BindMouseDown(OxyMouseButton.Left, PlotCommands.PanAt);
127155
return new Example(pm, controller);
128156
}
129157
}
130-
}
158+
}

Source/Examples/ExampleLibrary/Series/FunctionSeriesExamples.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ namespace ExampleLibrary
88
{
99
using System;
1010

11+
using ExampleLibrary.Utilities;
12+
1113
using OxyPlot;
1214
using OxyPlot.Annotations;
1315
using OxyPlot.Axes;
@@ -17,11 +19,17 @@ namespace ExampleLibrary
1719
public class FunctionSeriesExamples
1820
{
1921
[Example("Square wave")]
20-
public static PlotModel CreateSquareWave()
22+
public static PlotModel SquareWave()
2123
{
2224
return CreateSquareWave(25);
2325
}
2426

27+
[Example("Square wave (transposed)")]
28+
public static PlotModel SquareWaveTransposed()
29+
{
30+
return SquareWave().Transpose();
31+
}
32+
2533
private static PlotModel CreateSquareWave(int n = 25)
2634
{
2735
var plot = new PlotModel { Title = "Square wave (Gibbs phenomenon)" };
@@ -318,4 +326,4 @@ private static PlotModel CreateParametricPlot(Func<double, double> fx, Func<doub
318326
return plot;
319327
}
320328
}
321-
}
329+
}

0 commit comments

Comments
 (0)