-
Notifications
You must be signed in to change notification settings - Fork 81
/
indicator.fsx
92 lines (77 loc) · 2.91 KB
/
indicator.fsx
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
(**
---
title: Indicator Charts
category: Finance Charts
categoryindex: 7
index: 5
---
*)
(*** 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
(**
# Indicator Charts
[![Binder]({{root}}img/badge-binder.svg)](https://mybinder.org/v2/gh/plotly/plotly.net/gh-pages?urlpath=/tree/home/jovyan/{{fsdocs-source-basename}}.ipynb) 
[![Notebook]({{root}}img/badge-notebook.svg)]({{root}}{{fsdocs-source-basename}}.ipynb)
*Summary:* This example shows how to create indicator charts in F#.
Indicator Charts visualize the evolution of a value compared to a reference value, optionally inside a range.
There are different types of indicator charts, depending on the `IndicatorMode` used in chart generation:
- `Delta`/`Number` (and combinations) simply shows if the value is increasing or decreasing compared to the reference
- Any combination of the above with `Gauge` adds a customizable gauge that indicates where the value lies inside a given range.
*)
open Plotly.NET
open Plotly.NET.TraceObjects
open Plotly.NET.LayoutObjects
let allIndicatorTypes =
[ Chart.Indicator(
value = 120.,
mode = StyleParam.IndicatorMode.NumberDeltaGauge,
Title = "Bullet gauge",
DeltaReference = 90.,
Range = StyleParam.Range.MinMax(-200., 200.),
GaugeShape = StyleParam.IndicatorGaugeShape.Bullet,
ShowGaugeAxis = false,
Domain = Domain.init (Row = 0, Column = 0)
)
Chart.Indicator(
value = 200.,
mode = StyleParam.IndicatorMode.NumberDeltaGauge,
Title = "Angular gauge",
Delta = IndicatorDelta.init (Reference = 160),
Range = StyleParam.Range.MinMax(0., 250.),
Domain = Domain.init (Row = 0, Column = 1)
)
Chart.Indicator(
value = 300.,
mode = StyleParam.IndicatorMode.NumberDelta,
Title = "number and delta",
DeltaReference = 90.,
Domain = Domain.init (Row = 1, Column = 0)
)
Chart.Indicator(
value = 40.,
mode = StyleParam.IndicatorMode.Delta,
Title = "delta",
DeltaReference = 90.,
Domain = Domain.init (Row = 1, Column = 1)
) ]
|> Chart.combine
|> Chart.withLayoutGridStyle (Rows = 2, Columns = 2)
|> Chart.withMarginSize (Left = 200)
(*** condition: ipynb ***)
#if IPYNB
allIndicatorTypes
#endif // IPYNB
(***hide***)
allIndicatorTypes |> GenericChart.toChartHTML
(***include-it-raw***)