forked from plotly/Plotly.NET
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdefaults.fsx
More file actions
98 lines (72 loc) · 2.29 KB
/
Copy pathdefaults.fsx
File metadata and controls
98 lines (72 loc) · 2.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
(**
---
title: Global default values
category: General
categoryindex: 1
index: 6
---
*)
(*** hide ***)
(*** condition: prepare ***)
#r "nuget: Newtonsoft.JSON, 13.0.1"
#r "nuget: DynamicObj, 2.0.0"
#r "nuget: Giraffe.ViewEngine.StrongName, 2.0.0-alpha1"
#r "../../src/Plotly.NET/bin/Release/netstandard2.0/Plotly.NET.dll"
Plotly.NET.Defaults.DefaultDisplayOptions <-
Plotly.NET.DisplayOptions.init (PlotlyJSReference = Plotly.NET.PlotlyJSReference.NoReference)
(*** condition: ipynb ***)
#if IPYNB
#r "nuget: Plotly.NET, {{fsdocs-package-version}}"
#r "nuget: Plotly.NET.Interactive, {{fsdocs-package-version}}"
#endif // IPYNB
(**
# Global default values
[](https://mybinder.org/v2/gh/plotly/plotly.net/gh-pages?urlpath=/tree/home/jovyan/{{fsdocs-source-basename}}.ipynb) 
[]({{root}}{{fsdocs-source-basename}}.fsx) 
[]({{root}}{{fsdocs-source-basename}}.ipynb)
Plotly.NET provides mutable global default values in the `Defaults` module.
These values are always used in Chart generation. The default values are:
|Value name|Value|
|---|---|
| DefaultWidth | `600` |
| DefaultHeight | `600` |
| DefaultConfig | `Config.init(Responsive = true)` |
| DefaultDisplayOptions | `DisplayOptions.init()` |
| DefaultTemplate | `ChartTemplates.plotly` |
## Changing default values
The following code replaces the default template from the global defaults:
*)
open Plotly.NET
let before = Chart.Point([ 1, 2 ])
(*** condition: ipynb ***)
#if IPYNB
before
#endif // IPYNB
(***hide***)
before |> GenericChart.toChartHTML
(***include-it-raw***)
Defaults.DefaultTemplate <- ChartTemplates.lightMirrored
let after = Chart.Point([ 1, 2 ])
(*** condition: ipynb ***)
#if IPYNB
after
#endif // IPYNB
(***hide***)
after |> GenericChart.toChartHTML
(***include-it-raw***)
(**
To use the default template again:
*)
Defaults.DefaultTemplate <- ChartTemplates.plotly
(**
## Ignoring global defaults
All Chart functions have a `UseDefaults` argument which, when set to `false`, will ignore all global defaults:
*)
let noDefaults = Chart.Point([ 1, 2 ], UseDefaults = false)
(*** condition: ipynb ***)
#if IPYNB
noDefaults
#endif // IPYNB
(***hide***)
noDefaults |> GenericChart.toChartHTML
(***include-it-raw***)