Skip to content

Commit 86357cf

Browse files
committed
#83: Add functionality to customize Lower and upper labels of range charts
1 parent a68db7d commit 86357cf

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

Diff for: src/Plotly.NET/Chart.fs

+10-4
Original file line numberDiff line numberDiff line change
@@ -624,10 +624,12 @@ type Chart =
624624
[<Optional;DefaultParameterValue(null)>] ?Color,
625625
[<Optional;DefaultParameterValue(null)>] ?RangeColor,
626626
[<Optional;DefaultParameterValue(null)>] ?Labels,
627+
[<Optional;DefaultParameterValue(null)>] ?UpperLabels,
628+
[<Optional;DefaultParameterValue(null)>] ?LowerLabels,
627629
[<Optional;DefaultParameterValue(null)>] ?TextPosition,
628630
[<Optional;DefaultParameterValue(null)>] ?TextFont,
629-
[<Optional;DefaultParameterValue(null)>] ?LowerName,
630-
[<Optional;DefaultParameterValue(null)>] ?UpperName) =
631+
[<Optional;DefaultParameterValue("lower" )>] ?LowerName: string,
632+
[<Optional;DefaultParameterValue("upper" )>] ?UpperName: string) =
631633

632634
let upperName = defaultArg UpperName "upper"
633635
let lowerName = defaultArg LowerName "lower"
@@ -655,14 +657,16 @@ type Chart =
655657
|> TraceStyle.TraceInfo(?Name = Some lowerName, Showlegend=false)
656658
|> TraceStyle.Line(Width=0.)
657659
|> TraceStyle.Marker(Color=if RangeColor.IsSome then RangeColor.Value else "rgba(0,0,0,0.5)")
660+
|> TraceStyle.TextLabel(?Text=LowerLabels,?Textposition=TextPosition,?Textfont=TextFont)
658661

659662
let upper =
660663
Trace.initScatter (
661664
TraceStyle.Scatter(X = x,Y = upper, Mode=StyleParam.Mode.Lines, ?Fillcolor=RangeColor, Fill=StyleParam.Fill.ToNext_y) )
662665
|> TraceStyle.TraceInfo(?Name = Some upperName, Showlegend=false)
663666
|> TraceStyle.Line(Width=0.)
664667
|> TraceStyle.Marker(Color=if RangeColor.IsSome then RangeColor.Value else "rgba(0,0,0,0.5)")
665-
668+
|> TraceStyle.TextLabel(?Text=UpperLabels,?Textposition=TextPosition,?Textfont=TextFont)
669+
666670
GenericChart.MultiChart ([lower;upper;trace],Layout(),Config(), DisplayOptions())
667671

668672

@@ -674,12 +678,14 @@ type Chart =
674678
[<Optional;DefaultParameterValue(null)>] ?Color,
675679
[<Optional;DefaultParameterValue(null)>] ?RangeColor,
676680
[<Optional;DefaultParameterValue(null)>] ?Labels,
681+
[<Optional;DefaultParameterValue(null)>] ?UpperLabels,
682+
[<Optional;DefaultParameterValue(null)>] ?LowerLabels,
677683
[<Optional;DefaultParameterValue(null)>] ?TextPosition,
678684
[<Optional;DefaultParameterValue(null)>] ?TextFont,
679685
[<Optional;DefaultParameterValue(null)>] ?LowerName,
680686
[<Optional;DefaultParameterValue(null)>] ?UpperName) =
681687
let x,y = Seq.unzip xy
682-
Chart.Range(x, y, upper, lower, mode, ?Name=Name,?ShowMarkers=ShowMarkers,?Showlegend=Showlegend,?Color=Color,?RangeColor=RangeColor,?Labels=Labels,?TextPosition=TextPosition,?TextFont=TextFont,?LowerName=LowerName,?UpperName=UpperName)
688+
Chart.Range(x, y, upper, lower, mode, ?Name=Name,?ShowMarkers=ShowMarkers,?Showlegend=Showlegend,?Color=Color,?RangeColor=RangeColor,?Labels=Labels,?UpperLabels=UpperLabels,?LowerLabels=LowerLabels,?TextPosition=TextPosition,?TextFont=TextFont,?LowerName=LowerName,?UpperName=UpperName)
683689

684690

685691
/// Emphasizes the degree of change over time and shows the relationship of the parts to a whole.

Diff for: src/Plotly.NET/Playground.fsx

+11
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,17 @@ open System.IO
6060
open Deedle
6161
open FSharpAux
6262

63+
Chart.Range(
64+
x = [1;2],
65+
y = [2;3],
66+
upper=[3;4],
67+
lower=[1;2],
68+
mode=StyleParam.Mode.Lines,
69+
UpperLabels=["upper1";"upper2"],
70+
LowerLabels=["lower1";"lower2"]
71+
)
72+
|> Chart.Show
73+
6374
let geoJson =
6475
Http.RequestString "https://raw.githubusercontent.com/plotly/datasets/master/geojson-counties-fips.json"
6576
|> JsonConvert.DeserializeObject

0 commit comments

Comments
 (0)