Skip to content

Commit ba3d65f

Browse files
committed
Fix BoxPlotSeries problems
1 parent 937d637 commit ba3d65f

9 files changed

Lines changed: 80 additions & 19 deletions

File tree

scripts/DataPoints.ps1

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,8 @@ function Add-OxyBoxPlotSeriesPoint {
314314
[object]$BoxBottom,
315315
[object]$Median,
316316
[object]$BoxTop,
317-
[object]$UpperWhistker
317+
[object]$UpperWhistker,
318+
[object[]]$Outlier
318319
)
319320

320321
$X = Convert-ParameterValue double $X
@@ -325,5 +326,13 @@ function Add-OxyBoxPlotSeriesPoint {
325326
$UpperWhistker = Convert-ParameterValue double $UpperWhistker
326327

327328
$p = New-Object OxyPlot.Series.BoxPlotItem $X, $LowerWhisker, $BoxBottom, $Median, $BoxTop, $UpperWhistker
329+
330+
if ($null -ne $Outlier -and $Outlier.Count -gt 0) {
331+
$Outlier = $Outlier | foreach {
332+
Convert-ParameterValue double $_
333+
}
334+
$p.Outliers.AddRange([double[]]$Outlier)
335+
}
336+
328337
$series.Items.Add($p)
329338
}

scripts/Misc.ps1

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ function Get-RequiredCategoryAxis {
6868
)
6969

7070
if ($Series -is [OxyPlot.Series.ColumnSeries] -or
71-
$Series -is [OxyPlot.Series.ErrorColumnSeries]) {
71+
$Series -is [OxyPlot.Series.ErrorColumnSeries] -or
72+
$Series -is [OxyPlot.Series.BoxPlotSeries]) {
7273
return "x"
7374
}
7475

scripts/Parameter.ps1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ Set-StrictMode -Version 3
33
$TypeMapping = @{
44
"System.Double" = "object"
55
"double" = "object"
6+
"double[]" = "object[]"
67
"OxyPlot.OxyColor" = "string"
78
"OxyPlot.OxyPalette" = "object[]"
89
"OxyPlot.OxyThickness" = "double[]"

scripts/Style.ps1

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,13 @@ function Add-OxyStyle {
1111

1212
$filteredTypes = New-Object Collections.Generic.List[object]
1313

14-
$result = @{}
14+
$general = @{}
15+
$specific = @{}
1516

1617
foreach ($filter in $Config.Keys) {
1718

1819
if ($filter -match "^\[") {
19-
$result[$filter] = $Config[$filter]
20+
$general[$filter] = $Config[$filter]
2021
continue
2122
}
2223

@@ -66,11 +67,22 @@ function Add-OxyStyle {
6667
$value = Convert-ParameterValue $prop.PropertyType.FullName $originalValue
6768
}
6869

69-
if ($result.Contains($t.FullName)) {
70-
$result[$t.Fullname][$filterProp] = $value
70+
$isGeneral = $filterType -match "[*?]"
71+
if ($isGeneral) {
72+
if ($general.Contains($t.FullName)) {
73+
$general[$t.Fullname][$filterProp] = $value
74+
}
75+
else {
76+
$general[$t.FullName] = @{ $filterProp = $value }
77+
}
7178
}
7279
else {
73-
$result[$t.FullName] = @{ $filterProp = $value }
80+
if ($specific.Contains($t.FullName)) {
81+
$specific[$t.Fullname][$filterProp] = $value
82+
}
83+
else {
84+
$specific[$t.FullName] = @{ $filterProp = $value }
85+
}
7486
}
7587

7688
}
@@ -82,7 +94,20 @@ function Add-OxyStyle {
8294

8395
}
8496

85-
$Styles[$StyleName] = $result
97+
foreach ($type in $specific.Keys) {
98+
if ($specific[$type] -is [Collections.IDictionary]) {
99+
foreach ($prop in $specific[$type].Keys) {
100+
if ($general.Contains($type)) {
101+
$general[$type][$prop] = $specific[$type][$prop]
102+
}
103+
else {
104+
$general[$type] = @{ $prop = $specific[$type][$prop] }
105+
}
106+
}
107+
}
108+
}
109+
110+
$Styles[$StyleName] = $general
86111
}
87112

88113
function Remove-OxyStyle {

styles/ggplot.Style.ps1

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,30 +31,33 @@ $config = @{
3131
"PlotModel.LegendFontSize" = $baseSize, "pt"
3232
"PlotModel.LegendLineSpacing" = $baseLineSize, "pt"
3333

34-
# Axis: Tick
34+
# *Axis: Tick
3535
"*Axis.TickStyle" = "Outside"
3636
"*Axis.TicklineColor" = "#4D4D4D"
3737
"*Axis.TextColor" = "#4D4D4D"
3838
"*Axis.FontSize" = ($baseSize * 0.8), "pt"
3939

40-
# Axis: MinorTick
40+
# *Axis: MinorTick
4141
"*Axis.MinorTickSize" = 0
4242

43-
# Axis: MajorGridline
43+
# *Axis: MajorGridline
4444
"*Axis.MajorGridlineStyle" = "Solid"
4545
"*Axis.MajorGridlineColor" = "White"
4646
"*Axis.MajorGridlineThickness" = "1px"
4747

48-
# Axis: MinorGridline
48+
# *Axis: MinorGridline
4949
"*Axis.MinorGridlineStyle" = "Solid"
5050
"*Axis.MinorGridlineColor" = "#F0F0F0"
5151
"*Axis.MinorGridlineThickness" = "1px"
5252

53-
# Axis: Title
53+
# *Axis: Title
5454
"*Axis.TitleFontSize" = ($baseSize * 1.2), "pt"
5555
"*Axis.TitleColor" = "#4D4D4D"
5656
"*Axis.AxisTitleDistance" = ($baseSize * 2), "pt"
5757

58+
# CategoryAxis: FontSize
59+
"CategoryAxis.FontSize" = $baseSize, "pt"
60+
5861
# *Series
5962
"*Series.StrokeThickness" = "1px"
6063
"*Series.StrokeColor" = "Automatic"
@@ -65,6 +68,12 @@ $config = @{
6568
"Scatter*Series.MarkerType" = "Diamond"
6669
"Scatter*Series.MarkerSize" = "3px"
6770

71+
# BoxPlotSeries
72+
"BoxPlotSeries.Fill" = "White"
73+
"BoxPlotSeries.StrokeThickNess" = "2pt"
74+
"BoxPlotSeries.WhiskerWidth" = 0
75+
"BoxPlotSeries.OutlierSize" = "3pt"
76+
6877
# PieSeries
6978
"PieSeries.StartAngle" = -90
7079
"PieSeries.Diameter" = 0.9

templates/XYSeries.template.ps1

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ end {
167167
$grouping = $false
168168
}
169169
170-
$dataCount = $<% $SeriesElement.Element[0].Name %>Data.Count
170+
$dataCount = (<% ($SeriesElement.Element.Name -replace "(.+)", '$$$1Data.Count') -join ", " %> | Measure -Maximum).Maximum
171171
foreach ($group in $GroupingKeys) {
172172
173173
<% } # if ($SeriesElement -ne $null) -%>
@@ -186,10 +186,12 @@ end {
186186
continue
187187
}
188188
<% foreach ($e in $SeriesElement.Element) { -%>
189-
<% if ($e.Name -ne "CategoryIndex") { -%>
190-
if ($i -lt $<% $e.Name %>Data.Count) { $<% $e.Name %>Element = $<% $e.Name %>Data[$i] } else { $<% $e.Name %>Element = $null }
191-
<% } else { -%>
189+
<% if ($e.Name -eq "CategoryIndex") { -%>
192190
if ($i -lt $CategoryIndexData.Count) { $CategoryIndexElement = $CategoryIndexData[$i] } else { $CategoryIndexElement = $catCount }
191+
<% } elseif ($e.Name -eq "X" -and $ClassName -match "BoxPlotSeries") { -%>
192+
if ($i -lt $XData.Count) { $XElement = $XData[$i] } else { $XElement = $catCount }
193+
<% } else { -%>
194+
if ($i -lt $<% $e.Name %>Data.Count) { $<% $e.Name %>Element = $<% $e.Name %>Data[$i] } else { $<% $e.Name %>Element = $null }
193195
<% } -%>
194196
<% } -%>
195197
<% $SeriesElement.Cmdlet %> $series<% $SeriesElement.Element | where { $_.Name -ne "Category" } | foreach { %> $<% $_.Name %>Element<% } %>

templates/template.build.ps1

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,9 @@ $DATAPOINTS.BoxPlot = @{
156156
@{ Name = "BoxBottom"; Class = "double" },
157157
@{ Name = "Median"; Class = "double"; Axis = "Y" },
158158
@{ Name = "BoxTop"; Class = "double" },
159-
@{ Name = "UpperWhisker"; Class = "double" }
159+
@{ Name = "UpperWhisker"; Class = "double" },
160+
@{ Name = "Outlier"; Class = "double[]" },
161+
@{ Name = "Category"; Class = "string" }
160162
)
161163
}
162164

tests/Series.Tests.ps1

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,17 @@ Describe "series creation cmdlets" {
6868
-BoxBottom 21,22,23,24,25,36 `
6969
-Median 31,32,33,34,35,36 `
7070
-BoxTop 41,42,43,44,45,46 `
71-
-UpperWhisker 51,52,53,54,55,56
71+
-UpperWhisker 51,52,53,54,55,56 `
72+
-Outlier @(@(1,2,3), @(4,5,6,7), @(8,9,10,11,12))
7273
$s | Should -BeOfType [OxyPlot.Series.BoxPlotSeries]
7374
$s.Items[0].X | Should -Be 1
7475
$s.Items[1].LowerWhisker | Should -Be 12
7576
$s.Items[2].BoxBottom | Should -Be 23
7677
$s.Items[3].Median | Should -Be 34
7778
$s.Items[4].BoxTop | Should -Be 45
7879
$s.Items[5].UpperWhisker | Should -Be 56
80+
$s.Items[0].Outliers.Count | Should -Be 3
81+
$s.Items[0].Outliers[2] | Should -Be 3
7982
}
8083

8184
It "can create a CandleStickAndVolumeSeries object" {

tests/Style.Tests.ps1

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,15 @@ Describe "Add-OxyStyle" {
3737
$style["OxyPlot.Series.ColumnSeries"]["FontSize"] | Should -Be (10 * 96)
3838
}
3939

40+
It "can override a specific definition over a general definition" {
41+
Add-OxyStyle TestStyle @{
42+
"*Series.FontSize" = 10
43+
"ColumnSeries.FontSize" = 20
44+
}
45+
46+
$style = Get-OxyStyle TestStyle
47+
$style["OxyPlot.Series.ColumnSeries"]["FontSize"] | Should -Be 20
48+
}
4049
}
4150

4251
Describe "Apply-OxyStyle" {

0 commit comments

Comments
 (0)