Skip to content

Commit 77f46c7

Browse files
committed
#253: Fix indicator steps being a single argument instead of a sequence
1 parent d4c33d9 commit 77f46c7

2 files changed

Lines changed: 18 additions & 61 deletions

File tree

src/Plotly.NET/Playground.fsx

Lines changed: 12 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -176,60 +176,17 @@ open Plotly.NET
176176
open System
177177
open Plotly.NET
178178

179-
[
180-
Chart.Range(
181-
x = [1;2;3;4;5],
182-
y = [2;2;3;4;6],
183-
upper= [4;6;7;5;7],
184-
lower= [0;0;0;1;5],
185-
mode = StyleParam.Mode.Lines_Markers,
186-
TextPosition = StyleParam.TextPosition.TopCenter,
187-
MarkerColor = Color.fromColorScaleValues[2;2;3;4;6],
188-
RangeColor = Color.fromString "rgba(0, 204, 150, 0.2)",
189-
LowerLine = Line.init(Width = 2., Color = Color.fromString "rgba(0, 204, 150, 0.4)"),
190-
LowerMarker = Marker.init(Color = Color.fromString "rgba(0, 204, 150, 0.6)"),
191-
UpperLine = Line.init(Width = 2., Color = Color.fromString "rgba(0, 204, 150, 0.4)"),
192-
UpperMarker = Marker.init(Color = Color.fromString "rgba(0, 204, 150, 0.6)"),
193-
MultiText = ["Mid1"; "Mid2"; "Mid3"; "Mid4"; "Mid5"],
194-
MultiLowerText = ["Lower1"; "Lower2"; "Lower3"; "Lower4"; "Lower5"],
195-
MultiUpperText = ["Upper1"; "Upper2"; "Upper3"; "Upper4"; "Upper5"],
196-
ShowLegend = true
179+
Chart.Indicator(
180+
200., StyleParam.IndicatorMode.NumberDeltaGauge,
181+
Title = "Angular gauge",
182+
Delta = IndicatorDelta.init(Reference=160),
183+
Range = StyleParam.Range.MinMax(0., 250.),
184+
Domain = Domain.init(Row = 0, Column = 1),
185+
Gauge = IndicatorGauge.init(
186+
Steps = [
187+
IndicatorStep.init(Range = StyleParam.Range.MinMax(0., 150.), Color = Color.fromKeyword Cyan)
188+
IndicatorStep.init(Range = StyleParam.Range.MinMax(150., 250.), Color = Color.fromKeyword Red)
189+
]
197190
)
198-
Chart.Range(
199-
x = [1;2;3;4;5],
200-
y = [2;2;3;4;6],
201-
upper= [4;6;7;5;7],
202-
lower= [0;0;0;1;5],
203-
mode = StyleParam.Mode.Lines_Markers,
204-
GroupName = "Second Range",
205-
TextPosition = StyleParam.TextPosition.TopCenter,
206-
MarkerColor = Color.fromColorScaleValues[2;2;3;4;6],
207-
RangeColor = Color.fromString "rgba(0, 204, 150, 0.2)",
208-
LowerLine = Line.init(Width = 2., Color = Color.fromString "rgba(0, 204, 150, 0.4)"),
209-
LowerMarker = Marker.init(Color = Color.fromString "rgba(0, 204, 150, 0.6)"),
210-
UpperLine = Line.init(Width = 2., Color = Color.fromString "rgba(0, 204, 150, 0.4)"),
211-
UpperMarker = Marker.init(Color = Color.fromString "rgba(0, 204, 150, 0.6)"),
212-
MultiText = ["Mid1"; "Mid2"; "Mid3"; "Mid4"; "Mid5"],
213-
MultiLowerText = ["Lower1"; "Lower2"; "Lower3"; "Lower4"; "Lower5"],
214-
MultiUpperText = ["Upper1"; "Upper2"; "Upper3"; "Upper4"; "Upper5"]
215-
)
216-
217-
]
218-
|> Chart.combine
219-
|> Chart.show
220-
221-
let rnd = System.Random(5)
222-
223-
let x = [1.; 2.; 3.; 4.; 5.; 6.; 7.; 8.; 9.; 10.; ]
224-
let y = [2.; 1.5; 5.; 1.5; 3.; 2.5; 2.5; 1.5; 3.5; 1.]
225-
226-
let yUpper = y |> List.map (fun v -> v + rnd.NextDouble())
227-
let yLower = y |> List.map (fun v -> v - rnd.NextDouble())
228-
Chart.Range(
229-
x,y,yUpper,yLower,
230-
StyleParam.Mode.Lines_Markers,
231-
MarkerColor=Color.fromString "grey",
232-
RangeColor=Color.fromString "lightblue",
233-
UseDefaults = false)
234-
191+
)
235192
|> Chart.show

src/Plotly.NET/Traces/ObjectAbstractions/Indicator.fs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ type IndicatorBar() =
130130

131131
indicatorBar)
132132

133-
type IndicatorSteps() =
133+
type IndicatorStep() =
134134
inherit DynamicObj()
135135

136136
static member init
@@ -142,8 +142,8 @@ type IndicatorSteps() =
142142
[<Optional; DefaultParameterValue(null)>] ?TemplateItemName: string,
143143
[<Optional; DefaultParameterValue(null)>] ?Thickness: float
144144
) =
145-
IndicatorSteps()
146-
|> IndicatorSteps.style (
145+
IndicatorStep()
146+
|> IndicatorStep.style (
147147
?Color = Color,
148148
?Line = Line,
149149
?Name = Name,
@@ -161,7 +161,7 @@ type IndicatorSteps() =
161161
[<Optional; DefaultParameterValue(null)>] ?TemplateItemName: string,
162162
[<Optional; DefaultParameterValue(null)>] ?Thickness: float
163163
) =
164-
(fun (indicatorSteps: IndicatorSteps) ->
164+
(fun (indicatorSteps: IndicatorStep) ->
165165

166166
Color |> DynObj.setValueOpt indicatorSteps "color"
167167
Line |> DynObj.setValueOpt indicatorSteps "line"
@@ -210,7 +210,7 @@ type IndicatorGauge() =
210210
[<Optional; DefaultParameterValue(null)>] ?BorderColor: Color,
211211
[<Optional; DefaultParameterValue(null)>] ?BorderWidth: int,
212212
[<Optional; DefaultParameterValue(null)>] ?Shape: StyleParam.IndicatorGaugeShape,
213-
[<Optional; DefaultParameterValue(null)>] ?Steps: IndicatorSteps,
213+
[<Optional; DefaultParameterValue(null)>] ?Steps: seq<IndicatorStep>,
214214
[<Optional; DefaultParameterValue(null)>] ?Threshold: IndicatorThreshold
215215
) =
216216
IndicatorGauge()
@@ -233,7 +233,7 @@ type IndicatorGauge() =
233233
[<Optional; DefaultParameterValue(null)>] ?BorderColor: Color,
234234
[<Optional; DefaultParameterValue(null)>] ?BorderWidth: int,
235235
[<Optional; DefaultParameterValue(null)>] ?Shape: StyleParam.IndicatorGaugeShape,
236-
[<Optional; DefaultParameterValue(null)>] ?Steps: IndicatorSteps,
236+
[<Optional; DefaultParameterValue(null)>] ?Steps: seq<IndicatorStep>,
237237
[<Optional; DefaultParameterValue(null)>] ?Threshold: IndicatorThreshold
238238
) =
239239
(fun (indicatorGauge: IndicatorGauge) ->

0 commit comments

Comments
 (0)