@@ -11,6 +11,7 @@ open GenericChart
11
11
module ChartExtensions =
12
12
13
13
open Trace
14
+ //open StyleParam
14
15
15
16
/// Provides a set of static methods for creating charts.
16
17
type Chart with
@@ -27,7 +28,20 @@ module ChartExtensions =
27
28
|> TraceStyle.TraceInfo( ?Name=( naming i Name),? Showlegend= Showlegend,? Legendgroup= Legendgroup,? Visible= Visible)
28
29
)
29
30
)
30
-
31
+
32
+ /// Set the axis anchor id the trace is belonging to
33
+ static member withAxisAnchor (? X ,? Y ,? Z ) =
34
+ let idx = if X.IsSome then Some ( StyleParam.AxisAnchorId.X X.Value) else None
35
+ let idy = if Y.IsSome then Some ( StyleParam.AxisAnchorId.Y Y.Value) else None
36
+ let idz = if Z.IsSome then Some ( StyleParam.AxisAnchorId.Z Z.Value) else None
37
+
38
+ ( fun ( ch : GenericChart ) ->
39
+ ch |> mapTrace ( fun trace ->
40
+ trace
41
+ |> TraceStyle.SetAxisAnchor( ?X= idx,? Y= idy,? Z= idz)
42
+ )
43
+ )
44
+
31
45
/// Apply styling to the Marker(s) of the chart as Object.
32
46
static member withMarker ( marker : Marker ) =
33
47
( fun ( ch : GenericChart ) ->
@@ -94,7 +108,7 @@ module ChartExtensions =
94
108
// ####################### Apply to layout
95
109
96
110
// Sets x-Axis of 2d and 3d- Charts
97
- static member withX_Axis ( xAxis : Axis.LinearAxis ) =
111
+ static member withX_Axis ( xAxis : Axis.LinearAxis ,? Id ) =
98
112
( fun ( ch : GenericChart ) ->
99
113
let contains3d =
100
114
ch
@@ -106,8 +120,9 @@ module ChartExtensions =
106
120
match contains3d with
107
121
| false ->
108
122
let layout =
123
+ let id = if Id.IsSome then StyleParam.AxisId.X Id.Value else StyleParam.AxisId.X 1
109
124
GenericChart.getLayout ch
110
- |> Layout.style ( xAxis = xAxis)
125
+ |> Layout.AddLinearAxis ( id , axis = xAxis)
111
126
GenericChart.setLayout layout ch
112
127
| true ->
113
128
let layout =
@@ -119,14 +134,16 @@ module ChartExtensions =
119
134
120
135
121
136
// Sets x-Axis of 2d and 3d- Charts
122
- static member withX_AxisStyle ( title ,? MinMax ,? Showgrid ,? Showline ) =
123
- let range = if MinMax.IsSome then Some ( StyleParam.Range.MinMax ( MinMax.Value)) else None
124
- let xaxis = Axis.LinearAxis.init( Title= title,? Range= range,? Showgrid= Showgrid,? Showline= Showline)
125
- Chart.withX_ Axis( xaxis)
137
+ static member withX_AxisStyle ( title ,? MinMax ,? Showgrid ,? Showline ,? Side ,? Overlaying ,? Id ,? Domain ,? Position ,? Anchor ) =
138
+ let range = if MinMax.IsSome then Some ( StyleParam.Range.MinMax ( MinMax.Value)) else None
139
+ let domain = if Domain.IsSome then Some ( StyleParam.Range.MinMax ( Domain.Value)) else None
140
+ let xaxis = Axis.LinearAxis.init( Title= title,? Range= range,? Showgrid= Showgrid,? Showline= Showline,
141
+ ?Anchor= Anchor,? Side= Side,? Domain= domain,? Overlaying= Overlaying,? Position= Position)
142
+ Chart.withX_ Axis( xaxis,? Id= Id)
126
143
127
144
128
145
// Sets y-Axis of 2d and 3d- Charts
129
- static member withY_Axis ( yAxis : Axis.LinearAxis ) =
146
+ static member withY_Axis ( yAxis : Axis.LinearAxis ,? Id ) =
130
147
( fun ( ch : GenericChart ) ->
131
148
let contains3d =
132
149
ch
@@ -138,8 +155,9 @@ module ChartExtensions =
138
155
match contains3d with
139
156
| false ->
140
157
let layout =
158
+ let id = if Id.IsSome then StyleParam.AxisId.Y Id.Value else StyleParam.AxisId.Y 1
141
159
GenericChart.getLayout ch
142
- |> Layout.style ( yAxis = yAxis)
160
+ |> Layout.AddLinearAxis ( id , axis = yAxis)
143
161
GenericChart.setLayout layout ch
144
162
| true ->
145
163
let layout =
@@ -149,10 +167,12 @@ module ChartExtensions =
149
167
)
150
168
151
169
// Sets y-Axis of 3d- Charts
152
- static member withY_AxisStyle ( title ,? MinMax ,? Showgrid ,? Showline ) =
153
- let range = if MinMax.IsSome then Some ( StyleParam.Range.MinMax ( MinMax.Value)) else None
154
- let yaxis = Axis.LinearAxis.init( Title= title,? Range= range,? Showgrid= Showgrid,? Showline= Showline)
155
- Chart.withY_ Axis( yaxis)
170
+ static member withY_AxisStyle ( title ,? MinMax ,? Showgrid ,? Showline ,? Side ,? Overlaying ,? Id ,? Domain ,? Position ,? Anchor ) =
171
+ let range = if MinMax.IsSome then Some ( StyleParam.Range.MinMax ( MinMax.Value)) else None
172
+ let domain = if Domain.IsSome then Some ( StyleParam.Range.MinMax ( Domain.Value)) else None
173
+ let yaxis = Axis.LinearAxis.init( Title= title,? Range= range,? Showgrid= Showgrid,
174
+ ?Showline= Showline,? Anchor= Anchor,? Side= Side,? Domain= domain,? Overlaying= Overlaying,? Position= Position)
175
+ Chart.withY_ Axis( yaxis,? Id= Id)
156
176
157
177
158
178
@@ -166,12 +186,46 @@ module ChartExtensions =
166
186
)
167
187
168
188
// Sets z-Axis style with ...
169
- static member withZ_AxisStyle ( title ,? MinMax ,? Showgrid ,? Showline ) =
170
- let range = if MinMax.IsSome then Some ( StyleParam.Range.MinMax ( MinMax.Value)) else None
171
- let zaxis = Axis.LinearAxis.init( Title= title,? Range= range,? Showgrid= Showgrid,? Showline= Showline)
189
+ static member withZ_AxisStyle ( title ,? MinMax ,? Showgrid ,? Showline ,? Domain ,? Anchor ) =
190
+ let range = if MinMax.IsSome then Some ( StyleParam.Range.MinMax ( MinMax.Value)) else None
191
+ let domain = if Domain.IsSome then Some ( StyleParam.Range.MinMax ( Domain.Value)) else None
192
+ let zaxis = Axis.LinearAxis.init( Title= title,? Range= range,? Showgrid= Showgrid,? Showline= Showline,? Anchor= Anchor,? Domain= domain)
172
193
Chart.withZ_ Axis( zaxis)
173
194
174
195
196
+ //// Sets second x-Axis of 2d- Charts
197
+ //static member withX_Axis2(xAxis2:Axis.LinearAxis) =
198
+ // (fun (ch:GenericChart) ->
199
+ // let layout =
200
+ // GenericChart.getLayout ch
201
+ // |> Layout.style (xAxis2=xAxis2)
202
+ // GenericChart.setLayout layout ch
203
+ // )
204
+
205
+
206
+ // // Sets second x-Axis of 2d- Charts
207
+ //static member withX_Axis2Style(title,?MinMax,?Showgrid,?Showline) =
208
+ // let range = if MinMax.IsSome then Some (StyleParam.Range.MinMax (MinMax.Value)) else None
209
+ // let xaxis = Axis.LinearAxis.init(Title=title,?Range=range,?Showgrid=Showgrid,?Showline=Showline,Side=StyleParam.Side.Top)
210
+ // Chart.withX_Axis2(xaxis)
211
+
212
+
213
+ //// Sets second y-Axis of 2d- Charts
214
+ //static member withY_Axis2(yAxis2:Axis.LinearAxis) =
215
+ // (fun (ch:GenericChart) ->
216
+ // let layout =
217
+ // GenericChart.getLayout ch
218
+ // |> Layout.style (yAxis2=yAxis2)
219
+ // GenericChart.setLayout layout ch
220
+ // )
221
+
222
+
223
+ // // Sets second x-Axis of 2d- Charts
224
+ //static member withY_Axis2Style(title,?MinMax,?Showgrid,?Showline) =
225
+ // let range = if MinMax.IsSome then Some (StyleParam.Range.MinMax (MinMax.Value)) else None
226
+ // let yaxis = Axis.LinearAxis.init(Title=title,?Range=range,?Showgrid=Showgrid,?Showline=Showline,Side=StyleParam.Side.Right)
227
+ // Chart.withY_Axis2(yaxis)
228
+
175
229
176
230
// Set the Layout options of a Chart
177
231
static member withLayout ( layout : Layout ) =
0 commit comments