@@ -11,6 +11,7 @@ open GenericChart
1111module ChartExtensions =
1212
1313 open Trace
14+ //open StyleParam
1415
1516 /// Provides a set of static methods for creating charts.
1617 type Chart with
@@ -27,7 +28,20 @@ module ChartExtensions =
2728 |> TraceStyle.TraceInfo( ?Name=( naming i Name),? Showlegend= Showlegend,? Legendgroup= Legendgroup,? Visible= Visible)
2829 )
2930 )
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+
3145 /// Apply styling to the Marker(s) of the chart as Object.
3246 static member withMarker ( marker : Marker ) =
3347 ( fun ( ch : GenericChart ) ->
@@ -94,7 +108,7 @@ module ChartExtensions =
94108// ####################### Apply to layout
95109
96110 // 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 ) =
98112 ( fun ( ch : GenericChart ) ->
99113 let contains3d =
100114 ch
@@ -106,8 +120,9 @@ module ChartExtensions =
106120 match contains3d with
107121 | false ->
108122 let layout =
123+ let id = if Id.IsSome then StyleParam.AxisId.X Id.Value else StyleParam.AxisId.X 1
109124 GenericChart.getLayout ch
110- |> Layout.style ( xAxis = xAxis)
125+ |> Layout.AddLinearAxis ( id , axis = xAxis)
111126 GenericChart.setLayout layout ch
112127 | true ->
113128 let layout =
@@ -119,14 +134,16 @@ module ChartExtensions =
119134
120135
121136 // 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)
126143
127144
128145 // 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 ) =
130147 ( fun ( ch : GenericChart ) ->
131148 let contains3d =
132149 ch
@@ -138,8 +155,9 @@ module ChartExtensions =
138155 match contains3d with
139156 | false ->
140157 let layout =
158+ let id = if Id.IsSome then StyleParam.AxisId.Y Id.Value else StyleParam.AxisId.Y 1
141159 GenericChart.getLayout ch
142- |> Layout.style ( yAxis = yAxis)
160+ |> Layout.AddLinearAxis ( id , axis = yAxis)
143161 GenericChart.setLayout layout ch
144162 | true ->
145163 let layout =
@@ -149,10 +167,12 @@ module ChartExtensions =
149167 )
150168
151169 // 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)
156176
157177
158178
@@ -166,12 +186,46 @@ module ChartExtensions =
166186 )
167187
168188 // 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)
172193 Chart.withZ_ Axis( zaxis)
173194
174195
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+
175229
176230 // Set the Layout options of a Chart
177231 static member withLayout ( layout : Layout ) =
0 commit comments