forked from plotly/Plotly.NET
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathannotations.fsx
73 lines (54 loc) · 1.87 KB
/
annotations.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
(**
---
title: Annotations
category: Chart Layout
categoryindex: 2
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
(**
# Annotations
[](https://mybinder.org/v2/gh/plotly/plotly.net/gh-pages?urlpath=/tree/home/jovyan/{{fsdocs-source-basename}}.ipynb) 
[]({{root}}{{fsdocs-source-basename}}.ipynb)
*Summary:* This example shows how to create Shapes and add them to the Charts in F#.
Let's first create some data for the purpose of creating example charts:
*)
open Plotly.NET
let x = [ 1.; 2.; 3.; 4.; 5.; 6.; 7.; 8.; 9.; 10. ]
let y = [ 2.; 1.5; 5.; 1.5; 3.; 2.5; 2.5; 1.5; 3.5; 1. ]
(**
Use the `Annotation.init` function to generate a shape, and either the `Chart.withAnnotation` or the `Chart.withAnnotations` function to add
multiple annotations at once.
*)
open Plotly.NET.LayoutObjects
let a1 = Annotation.init (X = 2., Y = 4., Text = "Hi there!")
let a2 =
Annotation.init (
X = 5.,
Y = 7.,
Text = "I am another annotation!",
BGColor = Color.fromString "white",
BorderColor = Color.fromString "black"
)
let annotations =
Chart.Line(x = x, y = y, Name = "line") |> Chart.withAnnotations ([ a1; a2 ])
(*** condition: ipynb ***)
#if IPYNB
annotations
#endif // IPYNB
(***hide***)
annotations |> GenericChart.toChartHTML
(***include-it-raw***)