-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
/
Copy path__init__.py
72 lines (61 loc) · 1.73 KB
/
__init__.py
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
"""
dashboard_objs
==========
A module for creating and manipulating dashboard content. You can create
a Dashboard object, insert boxes, swap boxes, remove a box and get an HTML
preview of the Dashboard.
The current workflow for making and manipulating dashboard follows:
1) Create a Dashboard
2) Modify the Dashboard (insert, swap, remove, etc)
3) Preview the Dashboard (run `.get_preview()`)
4) Repeat steps 2) and 3) as long as desired
The basic box object that your insert into a dashboard is just a `dict`.
The minimal dict for a box is:
```
{
'type': 'box',
'boxType': 'plot'
}
```
where 'fileId' can be set to the 'username:#' of your plot. The other
parameters
a box takes are `shareKey` (default is None) and `title` (default is '').
You will need to use the `.get_preview()` method quite regularly as this will
return an HTML representation of the dashboard in which the boxes in the HTML
are labelled with on-the-fly-generated numbers which change after each
modification to the dashboard.
Example: Create a simple Dashboard object
```
import plotly.dashboard_objs as dashboard
box_1 = {
'type': 'box',
'boxType': 'plot',
'fileId': 'username:some#',
'title': 'box 1'
}
box_2 = {
'type': 'box',
'boxType': 'plot',
'fileId': 'username:some#',
'title': 'box 2'
}
box_3 = {
'type': 'box',
'boxType': 'plot',
'fileId': 'username:some#',
'title': 'box 3'
}
my_dboard = dashboard.Dashboard()
my_dboard.insert(box_1)
# my_dboard.get_preview()
my_dboard.insert(box_2, 'above', 1)
# my_dboard.get_preview()
my_dboard.insert(box_3, 'left', 2)
# my_dboard.get_preview()
my_dboard.swap(1, 2)
# my_dboard.get_preview()
my_dboard.remove(1)
# my_dboard.get_preview()
```
"""
from . dashboard_objs import Dashboard