Skip to content

Commit 7d2bef7

Browse files
committed
Fix: formatters.fsx
1 parent 42fa161 commit 7d2bef7

File tree

8 files changed

+220
-240
lines changed

8 files changed

+220
-240
lines changed

docs/content/contour-plots.fsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,15 @@ The contour plot is an alternative to a 3-D surface plot.
1919
open System
2020
open FSharp.Plotly
2121

22+
23+
// Generate linearly spaced vector
2224
let linspace (min,max,n) =
2325
if n <= 2 then failwithf "n needs to be larger then 2"
2426
let bw = float (max - min) / (float n - 1.)
2527
[|min ..bw ..max|]
2628

2729

30+
// Create example data
2831
let size = 100
2932
let x = linspace(-2. * Math.PI, 2. * Math.PI, size)
3033
let y = linspace(-2. * Math.PI, 2. * Math.PI, size)

docs/content/index.fsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
(*** hide ***)
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.
4-
#I "../../bin"
4+
#r "../../bin/Newtonsoft.Json.dll"
55

66
(**
77
FSharp.Plotly
@@ -12,7 +12,7 @@ The library FSharp.Plotly implements charting suitable for use from F# scripting
1212
FSharp.Plotly is powered by popular JavaScript charting library [Plotly](https://plot.ly/). The library provides a complete mapping for the configuration options of the underlying library but empowers you to use the comfortable style known from the beautiful library [F# Charting](http://fslab.org/FSharp.Charting/). So you get a nice F# interface support with the full power of Plotly.
1313
*)
1414

15-
#r "FSharp.Plotly.dll"
15+
#r "../../bin/FSharp.Plotly.dll"
1616
open FSharp.Plotly
1717

1818
(**
@@ -31,7 +31,7 @@ Create the combined chart
3131
[
3232
Chart.Point(x,y,Name="scattern");
3333
Chart.Line(x,y',Name="line")
34-
|> Chart.withLineStyle(Width=1);
34+
|> Chart.withLineStyle(Width=2);
3535
]
3636
|> Chart.Combine
3737
(*** include-it:pie1 ***)

docs/content/pie-daughnut-charts.fsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,5 @@ Chart.Pie(values,labels)
2222
(*** include-it:pie1 ***)
2323

2424
(*** define-output:doughnut1 ***)
25-
Chart.Doughnut(values,labels,hole=0.3)
25+
Chart.Doughnut(values,labels,Hole=0.3)
2626
(*** include-it:doughnut1 ***)

docs/files/img/logo.png

15.7 KB
Loading

docs/tools/formatters.fsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ let createFsiEvaluator root output =
4141
img.Save(output @@ "images" @@ file, System.Drawing.Imaging.ImageFormat.Png)
4242
Some [ Paragraph [DirectImage ("", (root + "/images/" + file, None))] ]
4343

44-
| :? GenericChart.GenericChart as ch ->
44+
| :? GenericChart.GenericChart<_> as ch ->
4545
// Just return the inline HTML for a Plotly chart
4646
let html = GenericChart.toChartHtmlWithSize 760 500 ch
4747
Some [InlineBlock <| html]

src/FSharp.Plotly/ChartExtensions.fs

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -48,22 +48,21 @@ module ChartExtensions =
4848
// |> Helpers.ApplyMarkerStyles(?size=Size,?color=Color,?symbol=Symbol,?opacity=Opacity)
4949
//
5050
// Chart.withMarkerOption(marker)
51-
//
52-
// /// Apply styling to the Line(s) of the chart as Object.
53-
// static member withLineOption(line:Line) =
54-
// (fun (ch:GenericChart) ->
55-
// ch |> mapTrace (fun gc ->
56-
// gc.set_line line
57-
// gc)
58-
// )
59-
//
60-
// /// Apply styling to the Line(s) of the chart.
61-
// static member withLineStyle(?Width,?Color,?Shape,?Dash,?Smoothing,?ColorScale) =
62-
// let line =
63-
// Line()
64-
// |> Helpers.ApplyLineStyles(?width=Width,?color=Color,?shape=Shape,?dash=Dash,?smoothing=Smoothing,?colorScale=ColorScale)
65-
//
66-
// Chart.withLineOption(line)
51+
52+
/// Apply styling to the Line(s) of the chart as Object.
53+
static member withLineOption(line:LineOptions) =
54+
(fun (ch:GenericChart<#Trace>) ->
55+
ch |> mapTrace (fun (trace:#Trace) ->
56+
match (ApplyHelper.tryUpdatePropertyValueFromName trace "line" line) with
57+
| Some trace' -> trace' |> unbox
58+
| None -> trace |> unbox
59+
)
60+
)
61+
62+
/// Apply styling to the Line(s) of the chart.
63+
static member withLineStyle(?Width,?Color,?Shape,?Dash,?Smoothing,?ColorScale) =
64+
let line = Options.Line(?Width=Width,?Color=Color,?Shape=Shape,?Dash=Dash,?Smoothing=Smoothing,?ColorScale=ColorScale)
65+
Chart.withLineOption(line)
6766

6867

6968
//

src/FSharp.Plotly/GenericChart.fs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ module HTML =
3131

3232
/// Module
3333
module GenericChart =
34-
34+
// 'T when 'T :> Trace
3535
type GenericChart<'T when 'T :> Trace> =
3636
| Chart of 'T * (Layout -> Layout) list option
3737
| MultiChart of 'T list * (Layout -> Layout) list option
@@ -127,7 +127,7 @@ module GenericChart =
127127
html
128128

129129
/// Converts a GenericChart to it HTML representation and set the size of the div
130-
let toChartHtmlWithSize (width:int) (height:int) gChart =
130+
let toChartHtmlWithSize (width:int) (height:int) (gChart:GenericChart<#Trace>) =
131131
let guid = Guid.NewGuid().ToString()
132132
let tracesJson =
133133
getTraces gChart

0 commit comments

Comments
 (0)