Skip to content

Commit 1c52ded

Browse files
committed
update docs: use named args only, use global plotly js reference, remove script download
1 parent 6e28dec commit 1c52ded

File tree

72 files changed

+712
-530
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+712
-530
lines changed

.config/dotnet-tools.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
"isRoot": true,
44
"tools": {
55
"fantomas-tool": {
6-
"version": "4.7.8",
6+
"version": "4.7.9",
77
"commands": [
88
"fantomas"
99
]
1010
},
1111
"fsdocs-tool": {
12-
"version": "15.0.1",
12+
"version": "17.2.2",
1313
"commands": [
1414
"fsdocs"
1515
]

build/BasicTasks.fs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,21 @@ let clean =
3030

3131
/// builds the solution file (dotnet build solution.sln)
3232
let buildSolution =
33-
BuildTask.create "BuildSolution" [ clean ] { solutionFile |> DotNet.build id }
33+
BuildTask.create "BuildSolution" [ clean ] {
34+
solutionFile
35+
|> DotNet.build (fun p ->
36+
let msBuildParams =
37+
{p.MSBuildParams with
38+
Properties = ([
39+
"warnon", "3390"
40+
])
41+
}
42+
{
43+
p with
44+
MSBuildParams = msBuildParams
45+
}
46+
)
47+
}
3448

3549
/// builds the individual project files (dotnet build project.*proj)
3650
///
@@ -50,6 +64,7 @@ let build = BuildTask.create "Build" [clean] {
5064
Properties = ([
5165
"AssemblyVersion", pInfo.AssemblyVersion
5266
"InformationalVersion", pInfo.AssemblyInformationalVersion
67+
"warnon", "3390"
5368
])
5469
}
5570
{

docs/00_0_basics.fsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,11 @@ index: 1
1313
(*** condition: prepare ***)
1414
#r "nuget: Newtonsoft.JSON, 13.0.1"
1515
#r "nuget: DynamicObj, 2.0.0"
16+
#r "nuget: Giraffe.ViewEngine, 1.4.0"
1617
#r "../src/Plotly.NET/bin/Release/netstandard2.0/Plotly.NET.dll"
1718

19+
Plotly.NET.Defaults.DefaultDisplayOptions <- Plotly.NET.DisplayOptions.init(PlotlyJSReference = Plotly.NET.PlotlyJSReference.NoReference)
20+
1821
(*** condition: ipynb ***)
1922
#if IPYNB
2023
#r "nuget: Plotly.NET, {{fsdocs-package-version}}"
@@ -23,7 +26,6 @@ index: 1
2326

2427
(**
2528
[![Binder]({{root}}img/badge-binder.svg)](https://mybinder.org/v2/gh/plotly/Plotly.NET/gh-pages?filepath={{fsdocs-source-basename}}.ipynb)&emsp;
26-
[![Script]({{root}}img/badge-script.svg)]({{root}}{{fsdocs-source-basename}}.fsx)&emsp;
2729
[![Notebook]({{root}}img/badge-notebook.svg)]({{root}}{{fsdocs-source-basename}}.ipynb)
2830
2931
# Plotly.NET basics
@@ -53,7 +55,7 @@ These are mirrored in Plotly.NET's central type, `GenericChart`:
5355
5456
The central type that gets created by all Chart constructors is `GenericChart`, which itself represents either a single chart or a multi chart (as a Discriminate Union type). It looks like this:
5557
56-
```fsharp
58+
```
5759
type GenericChart =
5860
| Chart of Trace * Layout * Config * DisplayOptions
5961
| MultiChart of Trace list * Layout * Config * DisplayOptions
@@ -76,13 +78,15 @@ Plotly.NET uses multiple layers of abstractions to generate valid plotly.js JSON
7678
The `Chart` module provides the highest layer of abstraction. Here, plotly.js trace types are broken down to the most common and useful styling options, and combined with common layout settings.
7779
It also provides composite charts which consist of multiple traces such as `Chart.Range`, which really is a combination of 3 scatter traces.
7880
81+
In general, we recommend always using named arguments - even for mandatory arguments - as future changes/addition to the API might change the argument order.
82+
7983
Here is an example on how to create a simple 2D point chart:
8084
*)
8185

8286
open Plotly.NET
8387

8488
let pointChart =
85-
Chart.Point([1,2; 3,4])
89+
Chart.Point(xy=[1,2; 3,4])
8690

8791
(*** condition: ipynb ***)
8892
#if IPYNB

docs/00_1_image-export.fsx

Lines changed: 4 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ index: 2
1313
(*** condition: prepare ***)
1414
#r "nuget: Newtonsoft.JSON, 13.0.1"
1515
#r "nuget: DynamicObj, 2.0.0"
16-
#r "nuget: PuppeteerSharp, 7.0.0"
16+
#r "nuget: Giraffe.ViewEngine, 1.4.0"
17+
#r "nuget: PuppeteerSharp, 9.0.2"
1718
#r "../src/Plotly.NET/bin/Release/netstandard2.0/Plotly.NET.dll"
1819
#r "../src/Plotly.NET.ImageExport/bin/Release/netstandard2.0/Plotly.NET.ImageExport.dll"
1920

@@ -27,7 +28,6 @@ index: 2
2728

2829
(**
2930
[![Binder]({{root}}img/badge-binder.svg)](https://mybinder.org/v2/gh/plotly/Plotly.NET/gh-pages?filepath={{fsdocs-source-basename}}.ipynb)&emsp;
30-
[![Script]({{root}}img/badge-script.svg)]({{root}}{{fsdocs-source-basename}}.fsx)&emsp;
3131
[![Notebook]({{root}}img/badge-notebook.svg)]({{root}}{{fsdocs-source-basename}}.ipynb)
3232
3333
# Static image export
@@ -78,20 +78,6 @@ exampleChart
7878
Height=300
7979
)
8080

81-
(*** condition: ipynb ***)
82-
#if IPYNB
83-
let imgString = $"""<img
84-
src= "{exampleChart|> Chart.toBase64JPGString(Width=300,Height=300)}"
85-
/>"""
86-
DisplayExtensions.DisplayAs(imgString,"text/html")
87-
#endif // IPYNB
88-
89-
(***hide***)
90-
$"""<img
91-
src= "{exampleChart|> Chart.toBase64JPGString(Width=300,Height=300)}"
92-
/>"""
93-
(***include-it-raw***)
94-
9581
(**
9682
## Generating URIs for static chart images
9783
@@ -105,6 +91,7 @@ By referencing the `Plotly.NET.ImageExport` package, you get access to:
10591
10692
*)
10793

94+
(***do-not-eval***)
10895
let base64JPG =
10996
exampleChart
11097
|> Chart.toBase64JPGString(
@@ -120,69 +107,4 @@ not even that is necessary and just the SVG string can be used.
120107
(***do-not-eval***)
121108
$"""<img
122109
src= "{base64JPG}"
123-
/>"""
124-
125-
(*** condition: ipynb ***)
126-
#if IPYNB
127-
let imgString = $"""<img
128-
src= "{base64JPG}"
129-
/>"""
130-
DisplayExtensions.DisplayAs(imgString,"text/html")
131-
#endif // IPYNB
132-
133-
(***hide***)
134-
$"""<img
135-
src= "{base64JPG}"
136-
/>"""
137-
138-
(***include-it-raw***)
139-
140-
(**
141-
SVGs can be included without the image tag:
142-
*)
143-
144-
let svgString =
145-
exampleChart
146-
|> Chart.toSVGString(
147-
Width=300,
148-
Height=300
149-
)
150-
151-
svgString.Substring(0,300)
152-
|> printfn "%s"
153-
154-
(***include-output***)
155-
156-
(**
157-
In fact, the images shown on this site are included just the same way.
158-
159-
## Including static images in dotnet interactive notebooks
160-
161-
To include the images in dotnet interactive, convert them to html tags as above and include them via
162-
dotnet interactive's `DisplayAs` function. The content type for PNG/JPG is "text/html", and "image/svg+xml" for SVG.
163-
*)
164-
165-
let base64PNGTag =
166-
let base64 =
167-
exampleChart
168-
|> Chart.toBase64PNGString(
169-
Width=300,
170-
Height=300
171-
)
172-
$"""<img src= "{base64JPG}"/>"""
173-
174-
let svgString2 =
175-
exampleChart
176-
|> Chart.toSVGString(
177-
Width=300,
178-
Height=300
179-
)
180-
181-
// DisplayExtensions.DisplayAs(base64PNG,"text/html")
182-
// DisplayExtensions.DisplayAs(svgString2,"image/svg+xml")
183-
184-
(*** condition: ipynb ***)
185-
#if IPYNB
186-
DisplayExtensions.DisplayAs(base64PNG,"text/html")
187-
DisplayExtensions.DisplayAs(svgString,"image/svg+xml")
188-
#endif // IPYNB
110+
/>"""

0 commit comments

Comments
 (0)