Skip to content

Commit 1aae098

Browse files
authored
Merge branch 'master' into master
2 parents 3c3edc3 + 3628540 commit 1aae098

16 files changed

+1912
-1371
lines changed

.paket/paket.exe

-62.8 KB
Binary file not shown.

paket.lock

Lines changed: 978 additions & 1249 deletions
Large diffs are not rendered by default.

src/FSharp.Plotly/Chart.fs

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ type Chart =
170170
|> TraceStyle.Line(Width=0)
171171
|> TraceStyle.Marker(Color=if RangeColor.IsSome then RangeColor.Value else "rgba(0,0,,0.5)")
172172

173-
GenericChart.MultiChart ([lower;upper;trace],Layout())
173+
GenericChart.MultiChart ([lower;upper;trace],Layout(),Config())
174174

175175

176176
/// Displays a range of data by plotting two Y values per data point, with each Y value being drawn as a line
@@ -473,8 +473,27 @@ type Chart =
473473
|> TraceStyle.Line(?Width=Width,?Color=Color,?Dash=Dash,?Colorscale=Colorscale)
474474
|> GenericChart.ofTraceObject
475475

476+
///Parallel categories diagram for multidimensional categorical data.
477+
static member ParallelCategories(dims:seq<'key*#seq<'values>>,?Range,?Constraintrange,?Color,?Colorscale,?Width,?Dash,?Domain,?Labelfont,?Tickfont,?Rangefont) =
478+
let dims' =
479+
dims |> Seq.map (fun (k,vals) ->
480+
Dimensions.init(vals)
481+
|> Dimensions.style(vals,?Range=Range,?Constraintrange=Constraintrange,Label=k)
482+
)
483+
Trace.initParallelCategories (
484+
TraceStyle.ParallelCategories(Dimensions=dims',?Domain=Domain,?Labelfont=Labelfont,?Tickfont=Tickfont,?Rangefont=Rangefont)
485+
)
486+
|> TraceStyle.Line(?Width=Width,?Color=Color,?Dash=Dash,?Colorscale=Colorscale)
487+
|> GenericChart.ofTraceObject
488+
489+
static member ParallelCategories(dims:seq<Dimensions>,?Color,?Colorscale,?Width,?Dash,?Domain,?Labelfont,?Tickfont,?Rangefont) =
490+
Trace.initParallelCategories (
491+
TraceStyle.ParallelCoord (Dimensions=dims,?Domain=Domain,?Labelfont=Labelfont,?Tickfont=Tickfont,?Rangefont=Rangefont)
492+
)
493+
|> TraceStyle.Line(?Width=Width,?Color=Color,?Dash=Dash,?Colorscale=Colorscale)
494+
|> GenericChart.ofTraceObject
476495

477-
/// Computes the choropleth map plot
496+
/// Computes the choropleth map plot
478497
static member ChoroplethMap(locations,z,?Text,?Locationmode,?Autocolorscale,?Colorscale,?Colorbar,?Marker,?Zmin,?Zmax) =
479498
Trace.initChoroplethMap (
480499
TraceStyle.ChoroplethMap (Locations=locations,Z=z,?Text=Text,?Locationmode=Locationmode,?Autocolorscale=Autocolorscale,

src/FSharp.Plotly/ChartExtensions.fs

Lines changed: 80 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,15 @@ module ChartExtensions =
236236
(fun (ch:GenericChart) ->
237237
GenericChart.addLayout layout ch)
238238

239+
static member withConfig (config:Config) =
240+
(fun (ch:GenericChart) ->
241+
GenericChart.setConfig config ch)
242+
243+
static member withAnnotations(annotations:seq<Annotation>) =
244+
(fun (ch:GenericChart) ->
245+
ch
246+
|> GenericChart.mapLayout
247+
(Layout.style (Annotations = annotations)))
239248

240249
// Set the title of a Chart
241250
static member withTitle(title,?Titlefont) =
@@ -326,50 +335,86 @@ module ChartExtensions =
326335
else
327336
s
328337

338+
let contains3d ch =
339+
ch
340+
|> existsTrace (fun t ->
341+
match t with
342+
| :? Trace3d -> true
343+
| _ -> false)
344+
329345
charts
330346
|> Seq.mapi (fun i ch ->
331347
let colI,rowI,index = (i%col+1), (i/col+1),(i+1)
332348
let xdomain = (colWidth * float (colI-1), (colWidth * float colI) - space )
333349
let ydomain = (1. - ((rowWidth * float rowI) - space ),1. - (rowWidth * float (rowI-1)))
334-
let xaxis,yaxis,layout =
335-
let layout = GenericChart.getLayout ch
336-
let xName, yName = StyleParam.AxisId.X 1 |> StyleParam.AxisId.toString, StyleParam.AxisId.Y 1 |> StyleParam.AxisId.toString
337-
match (layout.TryGetTypedValue<Axis.LinearAxis> xName),(layout.TryGetTypedValue<Axis.LinearAxis> yName) with
338-
| Some x, Some y ->
339-
// remove axis
340-
DynObj.remove layout xName
341-
DynObj.remove layout yName
342-
343-
x |> Axis.LinearAxis.style(Anchor=StyleParam.AxisAnchorId.Y index,Domain=StyleParam.Range.MinMax xdomain),
344-
y |> Axis.LinearAxis.style(Anchor=StyleParam.AxisAnchorId.X index,Domain=StyleParam.Range.MinMax ydomain),
345-
layout
346-
| Some x, None ->
347-
// remove x - axis
348-
DynObj.remove layout xName
349-
x |> Axis.LinearAxis.style(Anchor=StyleParam.AxisAnchorId.Y index,Domain=StyleParam.Range.MinMax xdomain),
350-
Axis.LinearAxis.init(Anchor=StyleParam.AxisAnchorId.X index,Domain=StyleParam.Range.MinMax ydomain),
351-
layout
352-
| None, Some y ->
353-
// remove y - axis
354-
DynObj.remove layout yName
355-
Axis.LinearAxis.init(Anchor=StyleParam.AxisAnchorId.Y index,Domain=StyleParam.Range.MinMax xdomain),
356-
y |> Axis.LinearAxis.style(Anchor=StyleParam.AxisAnchorId.X index,Domain=StyleParam.Range.MinMax ydomain),
357-
layout
358-
| None, None ->
359-
Axis.LinearAxis.init(Anchor=StyleParam.AxisAnchorId.Y index,Domain=StyleParam.Range.MinMax xdomain),
360-
Axis.LinearAxis.init(Anchor=StyleParam.AxisAnchorId.X index,Domain=StyleParam.Range.MinMax ydomain),
361-
layout
362-
363-
ch
364-
|> GenericChart.setLayout layout
365-
|> Chart.withAxisAnchor(X=index,Y=index)
366-
|> Chart.withX_Axis(xaxis,index)
367-
|> Chart.withY_Axis(yaxis,index)
350+
351+
if contains3d ch then
352+
let sceneName = sprintf "scene%i" (i+1)
353+
354+
let scene =
355+
Scene.init (
356+
Domain =
357+
Domain.init(X = StyleParam.Range.MinMax xdomain,Y= StyleParam.Range.MinMax ydomain)
358+
)
359+
let layout =
360+
GenericChart.getLayout ch
361+
|> Layout.AddScene (
362+
sceneName,
363+
scene
364+
)
365+
ch
366+
|> mapTrace
367+
(fun t ->
368+
t?scene <- sceneName
369+
t
370+
)
371+
|> GenericChart.setLayout layout
372+
//|> Chart.withAxisAnchor(X=index,Y=index)
373+
else
374+
375+
let xaxis,yaxis,layout =
376+
let layout = GenericChart.getLayout ch
377+
let xName, yName = StyleParam.AxisId.X 1 |> StyleParam.AxisId.toString, StyleParam.AxisId.Y 1 |> StyleParam.AxisId.toString
378+
match (layout.TryGetTypedValue<Axis.LinearAxis> xName),(layout.TryGetTypedValue<Axis.LinearAxis> yName) with
379+
| Some x, Some y ->
380+
// remove axis
381+
DynObj.remove layout xName
382+
DynObj.remove layout yName
383+
384+
x |> Axis.LinearAxis.style(Anchor=StyleParam.AxisAnchorId.Y index,Domain=StyleParam.Range.MinMax xdomain),
385+
y |> Axis.LinearAxis.style(Anchor=StyleParam.AxisAnchorId.X index,Domain=StyleParam.Range.MinMax ydomain),
386+
layout
387+
| Some x, None ->
388+
// remove x - axis
389+
DynObj.remove layout xName
390+
x |> Axis.LinearAxis.style(Anchor=StyleParam.AxisAnchorId.Y index,Domain=StyleParam.Range.MinMax xdomain),
391+
Axis.LinearAxis.init(Anchor=StyleParam.AxisAnchorId.X index,Domain=StyleParam.Range.MinMax ydomain),
392+
layout
393+
| None, Some y ->
394+
// remove y - axis
395+
DynObj.remove layout yName
396+
Axis.LinearAxis.init(Anchor=StyleParam.AxisAnchorId.Y index,Domain=StyleParam.Range.MinMax xdomain),
397+
y |> Axis.LinearAxis.style(Anchor=StyleParam.AxisAnchorId.X index,Domain=StyleParam.Range.MinMax ydomain),
398+
layout
399+
| None, None ->
400+
Axis.LinearAxis.init(Anchor=StyleParam.AxisAnchorId.Y index,Domain=StyleParam.Range.MinMax xdomain),
401+
Axis.LinearAxis.init(Anchor=StyleParam.AxisAnchorId.X index,Domain=StyleParam.Range.MinMax ydomain),
402+
layout
403+
404+
ch
405+
|> GenericChart.setLayout layout
406+
|> Chart.withAxisAnchor(X=index,Y=index)
407+
|> Chart.withX_Axis(xaxis,index)
408+
|> Chart.withY_Axis(yaxis,index)
368409
)
369410

370411
|> Chart.Combine
371412
)
372-
413+
414+
//static member Stack3D (?Columns:int, ?Space) =
415+
// (fun (charts:#seq<GenericChart>) ->
416+
// ()
417+
// )
373418

374419
/// Save chart as html single page
375420
static member SaveHtmlAs pathName (ch:GenericChart,?Verbose) =

0 commit comments

Comments
 (0)