Skip to content

Commit 6bfc9e3

Browse files
author
bvenn
committed
add table chart
1 parent d9ffb5f commit 6bfc9e3

File tree

7 files changed

+185
-3
lines changed

7 files changed

+185
-3
lines changed

Diff for: FSharp.Plotly.sln

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Microsoft Visual Studio Solution File, Format Version 12.00
2-
# Visual Studio Version 16
3-
VisualStudioVersion = 16.0.29613.14
2+
# Visual Studio 15
3+
VisualStudioVersion = 15.0.28307.960
44
MinimumVisualStudioVersion = 10.0.40219.1
55
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".paket", ".paket", "{63297B98-5CED-492C-A5B7-A5B4F73CF142}"
66
ProjectSection(SolutionItems) = preProject
@@ -55,6 +55,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "content", "content", "{8E6D
5555
docsrc\content\sankey.fsx = docsrc\content\sankey.fsx
5656
docsrc\content\shapes.fsx = docsrc\content\shapes.fsx
5757
docsrc\content\splom.fsx = docsrc\content\splom.fsx
58+
docsrc\content\table.fsx = docsrc\content\table.fsx
5859
docsrc\content\violin-plots.fsx = docsrc\content\violin-plots.fsx
5960
docsrc\content\windrose-charts.fsx = docsrc\content\windrose-charts.fsx
6061
EndProjectSection

Diff for: src/FSharp.Plotly/Cellcolor.fs

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
namespace FSharp.Plotly
2+
3+
open System
4+
5+
/// CellColor type inherits from dynamic object
6+
type CellColour () =
7+
inherit DynamicObj ()
8+
9+
/// Initialized Line object
10+
static member init
11+
(
12+
?Color
13+
) =
14+
CellColour ()
15+
|> CellColour.style
16+
(
17+
?Color = Color
18+
)
19+
// Applies the styles to CellColour()
20+
static member style
21+
(
22+
?Color
23+
) =
24+
(fun (cell:CellColour) ->
25+
Color |> DynObj.setValueOpt cell "color"
26+
// out ->
27+
cell
28+
)
29+
30+

Diff for: src/FSharp.Plotly/Cells.fs

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
namespace FSharp.Plotly
2+
3+
open System
4+
5+
6+
/// Cells type inherits from dynamic object
7+
type Cells () =
8+
inherit DynamicObj ()
9+
10+
/// Initialized Cells object
11+
static member init
12+
(
13+
Values ,
14+
?Align ,
15+
?Height,
16+
?Fill ,
17+
?Font ,
18+
?Line
19+
20+
) =
21+
Cells()
22+
|> Cells.style
23+
(
24+
Values = Values,
25+
?Align = Align ,
26+
?Height = Height,
27+
?Fill = Fill ,
28+
?Font = Font ,
29+
?Line = Line
30+
31+
)
32+
33+
//Applies the styles to Cells()
34+
static member style
35+
(
36+
Values : seq<#seq<#IConvertible>> ,
37+
?Align : seq<StyleParam.HorizontalAlign>,
38+
?Height ,
39+
?Fill ,
40+
?Font : Font ,
41+
?Line : Line
42+
43+
) =
44+
(fun (cells: Cells) ->
45+
46+
Values |> DynObj.setValue cells "values"
47+
Align |> DynObj.setValueOptBy cells "align" (Seq.map StyleParam.HorizontalAlign.convert)
48+
Height |> DynObj.setValueOpt cells "height"
49+
Fill |> DynObj.setValueOpt cells "fill"
50+
Line |> DynObj.setValueOpt cells "line"
51+
Font |> DynObj.setValueOpt cells "font"
52+
cells
53+
)

Diff for: src/FSharp.Plotly/Chart.fs

+24-1
Original file line numberDiff line numberDiff line change
@@ -573,4 +573,27 @@ type Chart =
573573
|> TraceStyle.TextLabel(?Text=Labels,?Textposition=TextPosition,?Textfont=TextFont)
574574
|> GenericChart.ofTraceObject
575575

576-
576+
/// cretes table out of header sequence and row sequences
577+
static member Table(headerValues, cellValues, ?AlignHeader, ?AlignCells, ?ColumnWidth, ?ColumnOrder, ?ColorHeader, ?ColorCells, ?FontHeader, ?FontCells, ?HeightHeader, ?HeightCells, ?LineHeader, ?LineCells) = //header, cells ) = //,?Name,?Showlegend,?MarkerSymbol,?Color,?Opacity,?Labels,?TextPosition,?TextFont,?Dash,?Width) =
578+
Trace.initTable (
579+
580+
let CellFilling =
581+
match ColorCells with
582+
| Some color -> Some (CellColour.init (?Color=ColorCells))
583+
| Option.None -> Option.None
584+
585+
let HeaderFilling =
586+
match ColorHeader with
587+
| Some color -> Some (CellColour.init (?Color=ColorHeader))
588+
| Option.None -> Option.None
589+
590+
591+
TraceStyle.Table (
592+
Header = Header.init (headerValues|> Seq.map seq, ?Align=AlignHeader, ?Fill=HeaderFilling, ?Font=FontHeader, ?Height=HeightHeader, ?Line=LineHeader),
593+
Cells =
594+
Cells.init(cellValues |> Seq.transpose, ?Align=AlignCells, ?Fill=CellFilling, ?Font=FontCells, ?Height=HeightCells, ?Line=LineCells),
595+
?ColumnWidth = ColumnWidth,
596+
?ColumnOrder = ColumnOrder
597+
)
598+
)
599+
|> GenericChart.ofTraceObject

Diff for: src/FSharp.Plotly/FSharp.Plotly.fsproj

+3
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@
2525
<Compile Include="Line.fs" />
2626
<Compile Include="Marker.fs" />
2727
<Compile Include="Font.fs" />
28+
<Compile Include="Cellcolor.fs" />
29+
<Compile Include="Header.fs" />
30+
<Compile Include="Cells.fs" />
2831
<Compile Include="Axis.fs" />
2932
<Compile Include="Bins.fs" />
3033
<Compile Include="Cumulative.fs" />

Diff for: src/FSharp.Plotly/Header.fs

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
namespace FSharp.Plotly
2+
3+
open System
4+
5+
/// Header type inherits from dynamic object
6+
type Header () =
7+
inherit DynamicObj ()
8+
9+
/// Initialized Header object
10+
static member init
11+
(
12+
Values ,
13+
?Align ,
14+
?Height,
15+
?Fill ,
16+
?Font ,
17+
?Line
18+
19+
) =
20+
Header()
21+
|> Header.style
22+
(
23+
Values = Values,
24+
?Align = Align ,
25+
?Height = Height,
26+
?Fill = Fill ,
27+
?Font = Font ,
28+
?Line = Line
29+
30+
)
31+
32+
/// Applies the styles to Header()
33+
static member style
34+
(
35+
Values : seq<#seq<#IConvertible>> ,
36+
?Align : seq<StyleParam.HorizontalAlign>,
37+
?Height ,
38+
?Fill ,
39+
?Font : Font ,
40+
?Line : Line
41+
42+
) =
43+
(fun (header: Header) ->
44+
45+
Values |> DynObj.setValue header "values"
46+
Align |> DynObj.setValueOptBy header "align" (Seq.map StyleParam.HorizontalAlign.convert)
47+
Height |> DynObj.setValueOpt header "height"
48+
Fill |> DynObj.setValueOpt header "fill"
49+
Line |> DynObj.setValueOpt header "line"
50+
Font |> DynObj.setValueOpt header "font"
51+
header
52+
)

Diff for: src/FSharp.Plotly/Trace.fs

+20
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,9 @@ module Trace =
7474
let initSplom (applyStyle:Trace->Trace) =
7575
Trace("splom") |> applyStyle
7676

77+
/// Init trace for table
78+
let initTable (applyStyle:Trace->Trace) =
79+
Trace("table") |> applyStyle
7780

7881
/// Functions provide the styling of the Chart objects
7982
type TraceStyle() =
@@ -966,3 +969,20 @@ module Trace =
966969
// out ->
967970
trace
968971
)
972+
973+
// Applies the styles of table plot to TraceObjects
974+
static member Table
975+
(
976+
Header : Header ,
977+
Cells : Cells ,
978+
?ColumnWidth : seq<int>,
979+
?ColumnOrder : seq<int>
980+
) =
981+
(fun (trace:('T :> Trace)) ->
982+
Header |> DynObj.setValue trace "header"
983+
Cells |> DynObj.setValue trace "cells"
984+
ColumnWidth |> DynObj.setValueOpt trace "columnwidth"
985+
ColumnOrder |> DynObj.setValueOpt trace "columnorder"
986+
// out ->
987+
trace
988+
)

0 commit comments

Comments
 (0)