@@ -212,16 +212,85 @@ module GenericChart =
212
212
// let l' = getLayouts gChart
213
213
// MultiChart (traces, Some (layouts@l'))
214
214
215
+ open Plotly.NET .LayoutObjects
215
216
// Combines two GenericChart
217
+
216
218
let combine ( gCharts : seq < GenericChart >) =
219
+ // temporary hard fix for some props, see https://github.com/CSBiology/DynamicObj/issues/11
220
+ let combineOptSeqs ( first : seq < 'A > option ) ( second : seq < 'A > option ) =
221
+ match first, second with
222
+ | Some f, Some s -> Some ( Seq.append f s)
223
+ | Some f, None -> Some f
224
+ | None, Some s -> Some s
225
+ | _ -> None
217
226
let combineLayouts ( first : Layout ) ( second : Layout ) =
218
- DynObj.combine first second |> unbox
227
+
228
+ let annotations =
229
+ combineOptSeqs
230
+ ( first.TryGetTypedValue< seq< Annotation>>( " annotations" ))
231
+ ( second.TryGetTypedValue< seq< Annotation>>( " annotations" ))
232
+
233
+ let shapes =
234
+ combineOptSeqs
235
+ ( first.TryGetTypedValue< seq< Shape>>( " shapes" ))
236
+ ( second.TryGetTypedValue< seq< Shape>>( " shapes" ))
237
+
238
+ let images =
239
+ combineOptSeqs
240
+ ( first.TryGetTypedValue< seq< LayoutImage>>( " images" ))
241
+ ( second.TryGetTypedValue< seq< LayoutImage>>( " images" ))
242
+
243
+ let sliders =
244
+ combineOptSeqs
245
+ ( first.TryGetTypedValue< seq< Slider>>( " sliders" ))
246
+ ( second.TryGetTypedValue< seq< Slider>>( " sliders" ))
247
+
248
+ let hiddenLabels =
249
+ combineOptSeqs
250
+ ( first.TryGetTypedValue< seq< string>>( " hiddenlabels" ))
251
+ ( second.TryGetTypedValue< seq< string>>( " hiddenlabels" ))
252
+
253
+ DynObj.combine first second
254
+ |> unbox
255
+ |> Layout.style(
256
+ ?Annotations = annotations,
257
+ ?Shapes = shapes,
258
+ ?Images = images,
259
+ ?Sliders = sliders,
260
+ ?HiddenLabels = hiddenLabels
261
+ )
219
262
220
263
let combineConfigs ( first : Config ) ( second : Config ) =
221
- DynObj.combine first second |> unbox
264
+
265
+ let editableAnnotations =
266
+ combineOptSeqs
267
+ ( first.TryGetTypedValue< seq< StyleParam.AnnotationEditOptions>>( " editable" ))
268
+ ( second.TryGetTypedValue< seq< StyleParam.AnnotationEditOptions>>( " editable" ))
269
+
270
+ let modeBarButtonsToAdd =
271
+ combineOptSeqs
272
+ ( first.TryGetTypedValue< seq< StyleParam.ModeBarButton>>( " modeBarButtonsToAdd" ))
273
+ ( second.TryGetTypedValue< seq< StyleParam.ModeBarButton>>( " modeBarButtonsToAdd" ))
274
+
275
+ DynObj.combine first second
276
+ |> unbox
277
+ |> Config.style(
278
+ ?EditableAnnotations = editableAnnotations,
279
+ ?ModeBarButtonsToAdd = modeBarButtonsToAdd
280
+ )
222
281
223
282
let combineDisplayOptions ( first : DisplayOptions ) ( second : DisplayOptions ) =
224
- DynObj.combine first second |> unbox
283
+
284
+ let additionalHeadTags =
285
+ combineOptSeqs
286
+ ( first.TryGetTypedValue< seq< string>>( " AdditionalHeadTags" ))
287
+ ( second.TryGetTypedValue< seq< string>>( " AdditionalHeadTags" ))
288
+
289
+ DynObj.combine first second
290
+ |> unbox
291
+ |> DisplayOptions.style(
292
+ ?AdditionalHeadTags = additionalHeadTags
293
+ )
225
294
226
295
gCharts
227
296
|> Seq.reduce ( fun acc elem ->
0 commit comments