@@ -27,33 +27,23 @@ module ChartExtensions =
2727 | _ -> trace
2828 )
2929 )
30- //
31- // /// Set the name related properties of a trace
32- // // TODO
33- // static member withTraceInfo(?textinfo,?textinfoposition,?hoverinfo) =
34- // (fun (ch:GenericChart) ->
35- // ch |> mapiTrace (fun i trace ->
36- // trace) // |> Helpers.ApplyTraceStyles())
37- // )
3830
39- // /// Apply styling to the Marker(s) of the chart as Object.
40- // static member withMarkerOption(marker:Marker) =
41- // (fun (ch:GenericChart) ->
42- // ch
43- // |> mapTrace (fun trace ->
44- // match box trace with
45- // | :? Trace as t when t:(member Walk : unit -> unit) -> t
46- // | t -> trace
47- // )
48- // )
31+ /// Apply styling to the Marker(s) of the chart as Object.
32+ static member withMarkerOption ( marker : MarkerOptions ) =
33+ ( fun ( ch : GenericChart ) ->
34+ ch |> mapTrace ( fun trace ->
35+ match trace with
36+ | :? IMarker as mTrace ->
37+ mTrace
38+ |> Options.IMarker( marker) :?> ITrace
39+ | _ -> trace
40+ )
41+ )
4942
50- // /// Apply styling to the Marker(s) of the chart.
51- // static member withMarkerStyle(?Size,?Color,?Symbol,?Opacity) =
52- // let marker =
53- // Marker()
54- // |> Helpers.ApplyMarkerStyles(?size=Size,?color=Color,?symbol=Symbol,?opacity=Opacity)
55- //
56- // Chart.withMarkerOption(marker)
43+ /// Apply styling to the Marker(s) of the chart.
44+ static member withMarkerStyle (? Size ,? Color ,? Symbol ,? Opacity ) =
45+ let marker = Options.Marker( ?Size= Size,? Color= Color,? Symbol= Symbol,? Opacity= Opacity)
46+ Chart.withMarkerOption( marker)
5747
5848 /// Apply styling to the Line(s) of the chart as Object.
5949 static member withLineOption ( line : LineOptions ) =
@@ -73,62 +63,118 @@ module ChartExtensions =
7363 Chart.withLineOption( line)
7464
7565
76- //
66+
7767 // ####################### Apply to layout
68+
69+ // Sets x-Axis of 2d and 3d- Charts
7870 static member withX_Axis ( xAxis : AxisOptions ) =
79- ( fun ( ch : GenericChart ) ->
80- let layout =
81- Options.Layout( xAxis= xAxis)
82- GenericChart.addLayout layout ch)
71+ ( fun ( ch : GenericChart ) ->
72+ let contains3d =
73+ ch
74+ |> existsTrace ( fun t ->
75+ match t with
76+ | :? ITrace3d -> true
77+ | _ -> false )
78+
79+ match contains3d with
80+ | false ->
81+ let layout =
82+ Options.Layout( xAxis= xAxis)
83+ GenericChart.addLayout layout ch
84+ | true ->
85+ let layout =
86+ Options.Layout( Scene= Options.Scene( xAxis= xAxis))
87+ GenericChart.addLayout layout ch
88+ )
89+
90+
8391
84- static member withX_AxisStyle ( title ,? MinMax ) =
85- ( fun ( ch : GenericChart ) ->
86- let range = if MinMax.IsSome then Some ( StyleOption.RangeValues.MinMax ( MinMax.Value)) else None
87- let xaxis = Options.Axis( Title= title,? Range= range)
88- let layout = Options.Layout( xAxis= xaxis)
89- GenericChart.addLayout layout ch)
90-
92+ // Sets x-Axis of 2d and 3d- Charts
93+ static member withX_AxisStyle ( title ,? MinMax ) =
94+ let range = if MinMax.IsSome then Some ( StyleOption.RangeValues.MinMax ( MinMax.Value)) else None
95+ let xaxis = Options.Axis( Title= title,? Range= range)
96+ Chart.withX_ Axis( xaxis)
97+
9198
99+ // Sets y-Axis of 2d and 3d- Charts
92100 static member withY_Axis ( yAxis : AxisOptions ) =
93- ( fun ( ch : GenericChart ) ->
101+ ( fun ( ch : GenericChart ) ->
102+ let contains3d =
103+ ch
104+ |> existsTrace ( fun t ->
105+ match t with
106+ | :? ITrace3d -> true
107+ | _ -> false )
108+
109+ match contains3d with
110+ | false ->
111+ let layout =
112+ Options.Layout( yAxis= yAxis)
113+ GenericChart.addLayout layout ch
114+ | true ->
115+ let layout =
116+ Options.Layout( Scene= Options.Scene( yAxis= yAxis))
117+ GenericChart.addLayout layout ch
118+ )
119+
120+ // Sets y-Axis of 3d- Charts
121+ static member withY_AxisStyle ( title ,? MinMax ) =
122+ let range = if MinMax.IsSome then Some ( StyleOption.RangeValues.MinMax ( MinMax.Value)) else None
123+ let yaxis = Options.Axis( Title= title,? Range= range)
124+ Chart.withY_ Axis( yaxis)
125+
126+
127+
128+ // Sets z-Axis of 3d- Charts
129+ static member withZ_Axis ( zAxis : AxisOptions ) =
130+ ( fun ( ch : GenericChart ) ->
94131 let layout =
95- Options.Layout( yAxis= yAxis)
96- GenericChart.addLayout layout ch)
132+ Options.Layout( Scene= Options.Scene( zAxis= zAxis))
133+ GenericChart.addLayout layout ch
134+ )
135+
136+ // Sets z-Axis of 3d- Charts
137+ static member withZ_AxisStyle ( title ,? MinMax ) =
138+ let range = if MinMax.IsSome then Some ( StyleOption.RangeValues.MinMax ( MinMax.Value)) else None
139+ let zaxis = Options.Axis( Title= title,? Range= range)
140+ Chart.withZ_ Axis( zaxis)
141+
142+
143+
97144
98- static member withY_AxisStyle ( title ,? MinMax ) =
99- ( fun ( ch : GenericChart ) ->
100- let range = if MinMax.IsSome then Some ( StyleOption.RangeValues.MinMax ( MinMax.Value)) else None
101- let yaxis = Options.Axis( Title= title,? Range= range)
102- let layout = Options.Layout( yAxis= yaxis)
103- GenericChart.addLayout layout ch)
104145
105146
147+
148+
149+ // Set the Layout options of a Chart
106150 static member withLayout ( layout : LayoutOptions ) =
107151 ( fun ( ch : GenericChart ) ->
108152 GenericChart.addLayout layout ch)
109-
153+
154+ // Set the size of a Chart
110155 static member withSize ( width , heigth ) =
111156 ( fun ( ch : GenericChart ) ->
112157 let layout = Options.Layout( Width= width, Height= heigth)
113158 GenericChart.addLayout layout ch)
114159
160+ // Set the margin of a Chart
115161 static member withMargin ( margin : MarginOptions ) =
116162 ( fun ( ch : GenericChart ) ->
117163 let layout = Options.Layout( Margin= margin)
118164 GenericChart.addLayout layout ch)
119165
166+ // Set the margin of a Chart
120167 static member withMarginSize (? Left ,? Right ,? Top ,? Bottom ,? Pad ,? Autoexpand ) =
121168 let margin = Options.Margin( ?Left= Left,? Right= Right,? Top= Top,? Bottom= Bottom,? Pad= Pad,? Autoexpand= Autoexpand)
122169 Chart.withMargin( margin)
123170
124171
125172
173+ // TODO: Include withLegend & withLegendStyle
126174
175+ // TODO: Include withError
127176
128- // // with Layout
129- // static member withError(layout:Layout) =
130- // (fun (ch:GenericChart) ->
131- // GenericChart.setLayout layout ch)
177+ // TODO: Include withShapes
132178
133179
134180
0 commit comments