Skip to content

Commit 52e5d87

Browse files
committed
Add ChartExtensions
1 parent af74487 commit 52e5d87

File tree

10 files changed

+63
-33
lines changed

10 files changed

+63
-33
lines changed

docs/content/contour-plots.fsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,4 @@ let z =
4444
z
4545
|> Chart.Contour
4646
|> Chart.withSize(600.,600.)
47-
(*** include-it:contour1 ***)
48-
|> Chart.Show
49-
50-
51-
47+
(*** include-it:contour1 ***)

docs/content/getting-started.fsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// This block of code is omitted in the generated HTML documentation. Use
33
// it to define helpers that you do not want to show in the documentation.
44
#r "../../bin/Newtonsoft.Json.dll"
5+
#r "../../lib/FSharp.Care.dll"
56

67
(**
78
FSharp.Plotly
@@ -36,5 +37,10 @@ GenericChart.ofTraceObject trace layout
3637
|> Chart.Show
3738

3839

40+
let red = FSharp.Care.Colors.Table.Office.red
41+
let red' = FSharp.Care.Colors.toHex false red
3942

43+
Chart.Point([1; 2; 3; 4],[12; 9; 15; 12])
44+
|> Chart.withMarkerStyle(Color=red')
45+
|> Chart.Show
4046

docs/tools/templates/template.cshtml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,16 +49,16 @@
4949
<li><a href="@Root/bubble-charts.html">Bubble Charts</a></li>
5050
<li><a href="@Root/contour-plots.html">Contour Plots</a></li>
5151
<li><a href="@Root/heatmaps.html">Heatmaps</a></li>
52-
<li><a href="@Root/histograms.html">Histograms</a></li>
53-
<li><a href="@Root/2d-histograms.html">2D Histograms</a></li>
52+
@*<li><a href="@Root/histograms.html">Histograms</a></li>
53+
<li><a href="@Root/2d-histograms.html">2D Histograms</a></li>*@
5454
<li><a href="@Root/line-scatter-plots.html">Line and Scatter Plots</a></li>
5555
<li><a href="@Root/pie-daughnut-charts.html">Pie and Doughnut Charts</a></li>
5656
<li><a href="@Root/polar-charts.html">Polar Charts</a></li>
5757
<li><a href="@Root/range-plots.html">Range Plots</a></li>
5858
<li class="nav-header">Plotly 3d-Charts</li>
59-
<li><a href="@Root/3d-line-plots.html">3D Line Plots</a></li>
60-
<li><a href="@Root/3d-scatter-plots.html">3D Scatter Plots</a></li>
61-
<li><a href="@Root/3d-surface-plots.html">3D Surface Plots</a></li>
59+
<li><a href="@Root/3d-scatter-plots.html">3D Scatter Plots</a></li>
60+
@*<li><a href="@Root/3d-line-plots.html">3D Line Plots</a></li>
61+
<li><a href="@Root/3d-surface-plots.html">3D Surface Plots</a></li>*@
6262
<li class="nav-header">Plotly WPF</li>
6363
<li><a href="@Root/plotly-wpf.html">Using Plotly PopUp window</a></li>
6464

lib/FSharp.Care.dll

-1 KB
Binary file not shown.

src/FSharp.Plotly/ChartExtensions.fs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,32 @@ module ChartExtensions =
6262
let line = Options.Line(?Width=Width,?Color=Color,?Shape=Shape,?Dash=Dash,?Smoothing=Smoothing,?ColorScale=ColorScale)
6363
Chart.withLineOption(line)
6464

65+
/// Apply styling to the xError(s) of the chart as Object (if member exists else it is ignored).
66+
static member withXError(xError:ErrorOptions) =
67+
(fun (ch:GenericChart) ->
68+
ch |> mapTrace (fun trace ->
69+
ApplyHelper.tryUpdatePropertyValueFromName trace "error_x" xError |> ignore
70+
trace
71+
)
72+
)
73+
74+
/// Apply styling to the yError(s) of the chart as Object (if member exists else it is ignored).
75+
static member withYError(yError:ErrorOptions) =
76+
(fun (ch:GenericChart) ->
77+
ch |> mapTrace (fun trace ->
78+
ApplyHelper.tryUpdatePropertyValueFromName trace "error_y" yError |> ignore
79+
trace
80+
)
81+
)
82+
83+
/// Apply styling to the zError(s) of the chart as Object (if member exists else it is ignored).
84+
static member withZError(zError:ErrorOptions) =
85+
(fun (ch:GenericChart) ->
86+
ch |> mapTrace (fun trace ->
87+
ApplyHelper.tryUpdatePropertyValueFromName trace "error_z" zError |> ignore
88+
trace
89+
)
90+
)
6591

6692

6793
// ####################### Apply to layout

src/FSharp.Plotly/Options.fs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,6 @@ type Options() =
223223
// Applies the styles to Error()
224224
static member Error
225225
(
226-
errorType,
227226
?Symmetric,
228227
?Array,
229228
?Arrayminus,
@@ -240,7 +239,6 @@ type Options() =
240239
?Arrayminussrc
241240
) =
242241
(fun (error:('T :> Error)) ->
243-
error.set_type errorType
244242
Symmetric |> Option.iter error.set_symmetric
245243
Array |> Option.iter error.set_array
246244
Arrayminus |> Option.iter error.set_arrayminus

src/FSharp.Plotly/Script.fsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,13 @@ let y = seq [5.; 2.5; 5.; 7.5; 5.; 2.5; 7.5; 4.5; 5.5; 5.]
1111
let y' = seq [2.; 1.5; 5.; 1.5; 3.; 2.5; 2.5; 1.5; 3.5; 1.]
1212

1313
Chart.Spline(x,y',Name="spline")
14-
|> Chart.withLineStyle(Width=2,Dash=StyleOption.DrawingStyle.Dot)
15-
|> Chart.withLineOption(Options.Line(Width=10))
16-
|> Chart.withX_AxisStyle("x axis title")
17-
|> Chart.withY_AxisStyle("y axis title")
14+
|> Chart.withYError(Options.Error(Array=[1.; 2.; 3.; 4.; 5.; 6.; 7.; 8.; 9.; 10.; ]))
15+
16+
17+
//|> Chart.withLineStyle(Width=2,Dash=StyleOption.DrawingStyle.Dot)
18+
//|> Chart.withLineOption(Options.Line(Width=10))
19+
//|> Chart.withX_AxisStyle("x axis title")
20+
//|> Chart.withY_AxisStyle("y axis title")
1821
//|> layoutJson
1922
//|> GenericChart.toChartHtmlWithSize 500 500
2023
|> Chart.Show
@@ -26,3 +29,4 @@ Chart.Spline(x,y',Name="spline")
2629

2730

2831

32+

src/FSharp.Plotly/Trace3dObjects.fs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ module Trace3dObjects =
4141
let mutable _surfaceaxis: _ option = None
4242
let mutable _surfacecolor: string option = None
4343
let mutable _projection: Projection option = None
44-
let mutable _error_x: Error_x option = None
45-
let mutable _error_y: Error_y option = None
46-
let mutable _error_z: Error_z option = None
44+
let mutable _error_x: Error option = None
45+
let mutable _error_y: Error option = None
46+
let mutable _error_z: Error option = None
4747
let mutable _scene: string option = None
4848
let mutable _xsrc: string option = None
4949
let mutable _ysrc: string option = None

src/FSharp.Plotly/TraceAuxiliaryObjects.fs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -122,14 +122,14 @@ module TraceAuxiliaryObjects =
122122
member __.ShouldSerializearraysrc() = not _arraysrc.IsNone
123123
member __.ShouldSerializearrayminussrc() = not _arrayminussrc.IsNone
124124

125-
type Error_x() =
126-
inherit Error()
127-
128-
type Error_y() =
129-
inherit Error()
130-
131-
type Error_z() =
132-
inherit Error()
125+
// type Error_x() =
126+
// inherit Error()
127+
//
128+
// type Error_y() =
129+
// inherit Error()
130+
//
131+
// type Error_z() =
132+
// inherit Error()
133133

134134
type Bins() =
135135

src/FSharp.Plotly/TraceObjects.fs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,8 @@ module TraceObjects =
168168

169169
let mutable _r: _ option = None
170170
let mutable _t: _ option = None
171-
let mutable _error_y: Error_y option = None
172-
let mutable _error_x: Error_x option = None
171+
let mutable _error_y: Error option = None
172+
let mutable _error_x: Error option = None
173173
let mutable _xaxis: string option = None
174174
let mutable _yaxis: string option = None
175175
let mutable _xsrc: string option = None
@@ -516,8 +516,8 @@ module TraceObjects =
516516

517517
let mutable _r: _ option = None
518518
let mutable _t: _ option = None
519-
let mutable _error_y: Error_y option = None
520-
let mutable _error_x: Error_x option = None
519+
let mutable _error_y: Error option = None
520+
let mutable _error_x: Error option = None
521521
let mutable _xaxis: string option = None
522522
let mutable _yaxis: string option = None
523523
let mutable _xsrc: string option = None
@@ -1933,8 +1933,8 @@ module TraceObjects =
19331933
let mutable _fillcolor: string option = None
19341934
let mutable _r: _ option = None
19351935
let mutable _t: _ option = None
1936-
let mutable _error_y: Error_y option = None
1937-
let mutable _error_x: Error_x option = None
1936+
let mutable _error_y: Error option = None
1937+
let mutable _error_x: Error option = None
19381938
let mutable _rsrc: string option = None
19391939
let mutable _tsrc: string option = None
19401940

0 commit comments

Comments
 (0)