@@ -27,33 +27,23 @@ module ChartExtensions =
27
27
| _ -> trace
28
28
)
29
29
)
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
- // )
38
30
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
+ )
49
42
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)
57
47
58
48
/// Apply styling to the Line(s) of the chart as Object.
59
49
static member withLineOption ( line : LineOptions ) =
@@ -73,62 +63,118 @@ module ChartExtensions =
73
63
Chart.withLineOption( line)
74
64
75
65
76
- //
66
+
77
67
// ####################### Apply to layout
68
+
69
+ // Sets x-Axis of 2d and 3d- Charts
78
70
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
+
83
91
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
+
91
98
99
+ // Sets y-Axis of 2d and 3d- Charts
92
100
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 ) ->
94
131
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
+
97
144
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)
104
145
105
146
147
+
148
+
149
+ // Set the Layout options of a Chart
106
150
static member withLayout ( layout : LayoutOptions ) =
107
151
( fun ( ch : GenericChart ) ->
108
152
GenericChart.addLayout layout ch)
109
-
153
+
154
+ // Set the size of a Chart
110
155
static member withSize ( width , heigth ) =
111
156
( fun ( ch : GenericChart ) ->
112
157
let layout = Options.Layout( Width= width, Height= heigth)
113
158
GenericChart.addLayout layout ch)
114
159
160
+ // Set the margin of a Chart
115
161
static member withMargin ( margin : MarginOptions ) =
116
162
( fun ( ch : GenericChart ) ->
117
163
let layout = Options.Layout( Margin= margin)
118
164
GenericChart.addLayout layout ch)
119
165
166
+ // Set the margin of a Chart
120
167
static member withMarginSize (? Left ,? Right ,? Top ,? Bottom ,? Pad ,? Autoexpand ) =
121
168
let margin = Options.Margin( ?Left= Left,? Right= Right,? Top= Top,? Bottom= Bottom,? Pad= Pad,? Autoexpand= Autoexpand)
122
169
Chart.withMargin( margin)
123
170
124
171
125
172
173
+ // TODO: Include withLegend & withLegendStyle
126
174
175
+ // TODO: Include withError
127
176
128
- // // with Layout
129
- // static member withError(layout:Layout) =
130
- // (fun (ch:GenericChart) ->
131
- // GenericChart.setLayout layout ch)
177
+ // TODO: Include withShapes
132
178
133
179
134
180
0 commit comments